public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/52764] New: Including <cstdint> after <stdint.h> fails to define limit macros
@ 2012-03-29  9:12 bmerry at gmail dot com
  2012-03-29 10:02 ` [Bug libstdc++/52764] " redi at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: bmerry at gmail dot com @ 2012-03-29  9:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52764

             Bug #: 52764
           Summary: Including <cstdint> after <stdint.h> fails to define
                    limit macros
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: bmerry@gmail.com


Created attachment 27027
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27027
Preprocessed source from g++ -v -save-temps -std=c++0x gcc-stdint.cpp

Both <cstdint> and <tr1/cstdint> are implemented by defining
__STDC_LIMIT_MACROS, including <stdint.h> and then undefining the macro again.
However, if <stdint.h> has already been included (which may occur indirectly
via some third-party C library header) then the limit macros do not get
defined.

I'm not 100% sure this is a bug because the C and C++ standards seem to
contradict each other, but here's my reasoning:

Both TR1 and C++11 are explicit that <cstdint> will define the limit macros,
and C++11 also says "The macros defined by <cstdint> are provided
unconditionally. In particular, the symbols __STDC_LIMIT_MACROS and
__STDC_CONSTANT_MACROS (mentioned in footnotes 219, 220, and 222 in the C
standard) play no role in C++."

TR1 also says that "[<stdint.h>] behaves as if it includes the header
<cstdint>, and provides sufficient using declarations to declare in the global
namespace all type names defined in the header <cstdint>."

I've run into this on GCC 4.6.1, but from a quick look at
http://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/include/c_global/cstdint@185951
it looks like this hasn't changed.


Command line: 
g++ -c -std=c++0x gcc-stdint.cpp

Output:
gcc-stdint.cpp:4:26: error: ‘UINT32_MAX’ was not declared in this scope

Output of g++ -v:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin
--enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-10-06 23:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-29  9:12 [Bug libstdc++/52764] New: Including <cstdint> after <stdint.h> fails to define limit macros bmerry at gmail dot com
2012-03-29 10:02 ` [Bug libstdc++/52764] " redi at gcc dot gnu.org
2012-03-29 10:08 ` paolo.carlini at oracle dot com
2012-03-29 10:29 ` redi at gcc dot gnu.org
2012-04-07 16:07 ` joseph at codesourcery dot com
2012-09-27 12:04 ` paolo.carlini at oracle dot com
2012-09-27 12:39 ` paolo.carlini at oracle dot com
2012-09-27 15:10 ` [Bug c++/52764] " paolo.carlini at oracle dot com
2012-10-06 23:06 ` paolo at gcc dot gnu.org
2012-10-06 23:11 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).