FS#30004 - [gcc] Including <limits> header file fails when compiling with -m32

Attached to Project: Arch Linux
Opened by Dan Liew (delcypher) - Thursday, 24 May 2012, 19:03 GMT
Last edited by Allan McRae (Allan) - Thursday, 24 May 2012, 20:40 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Allan McRae (Allan)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description: When using C++ code that uses numeric_limits<> and using the g++ option -m32 on a 64-bit system the code fails to compile with a pretty unhelpful error message. I'm not completely sure if this is a bug.

Additional info:
Related packages installed:
local/gcc 4.7.0-6 (base-devel)
The GNU Compiler Collection - C and C++ frontends
local/gcc-ada 4.7.0-6
Ada front-end for GCC (GNAT)
local/gcc-libs 4.7.0-6 (base)
Runtime libraries shipped by GCC
local/lcov 1.9-1
front-end for GCC's coverage testing tool gcov
local/lib32-gcc-libs 4.7.0-6
Runtime libraries shipped by GCC (32-bit)

This is on a x86_64 Arch Linux install.

Steps to reproduce:
1. Try to compile the attached file "limits.cpp" with the following command
$ g++ -m32 limits.cpp

2. The following error is shown
In file included from limits.cpp:1:0:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/limits:1405:35:
error: template argument 1 is invalid
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/limits:1479:44:
error: template argument 1 is invalid

If -m64 is used instead of -m32 the program compiles with out error.

Compiling with the -v option can be seen here http://pastebin.com/JRJcVDX2 . I noticed that there was a message relating to mismatching headers and libraries but I'm not sure if it is an issue.
This task depends upon

Closed by  Allan McRae (Allan)
Thursday, 24 May 2012, 20:40 GMT
Reason for closing:  Not a bug
Comment by Evangelos Foutras (foutrelis) - Thursday, 24 May 2012, 19:55 GMT
You might need to install gcc-multilib.
Comment by Dan Liew (delcypher) - Thursday, 24 May 2012, 20:01 GMT
Thanks for the tip. I've done that and everything works as expected now. I foolishly assumed that Arch only had one gcc package and that installing lib32-gcc-libs and lib32-libstdc++5 would be sufficient to compile 32-bit executables.

Loading...