Bug 15366 - Per C11 and C++11, <stdint.h> should not look at __STDC_LIMIT_MACROS or __STDC_CONSTANT_MACROS
Summary: Per C11 and C++11, <stdint.h> should not look at __STDC_LIMIT_MACROS or __STD...
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 2.18
Assignee: Paul Pluzhnikov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-13 00:32 UTC by Richard Smith
Modified: 2017-02-28 13:07 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Smith 2013-04-13 00:32:50 UTC
glibc's <stdint.h> follows C99, which says that in C++, certain macros should only be defined if __STDC_LIMIT_MACROS or __STDC_CONSTANT_MACROS is defined. However, the C++ committee decided that they didn't want this behavior, and explicitly overruled this in the C++11 standard (the first to provide <stdint.h>). Consequently C11 removed these rules. glibc has not been updated to follow the C11 rules, and still checks for those macros being defined in C++ mode.

C++ implementations are currently working around this by wrapping glibc's <stdint.h> with one which defines these macros first. These workarounds should not be necessary; glibc should simply not be checking for these macros. Fix would be to remove these lines from sysdeps/generic/stdint.h:

/* The ISO C99 standard specifies that in C++ implementations these
   macros should only be defined if explicitly requested.  */
#if !defined __cplusplus || defined __STDC_LIMIT_MACROS

... plus the corresponding #endif and the corresponding lines for __STDC_CONSTANT_MACROS.
Comment 1 Paul Pluzhnikov 2013-04-15 23:32:47 UTC
Google ref: b/8607032
Proposed patch: http://sourceware.org/ml/libc-alpha/2013-04/msg00473.html
Comment 2 OndrejBilka 2013-05-21 14:17:33 UTC
Was according to http://sourceware.org/ml/libc-alpha/2013-04/msg00677.html
commited.
Comment 3 Florian Weimer 2016-11-24 18:18:08 UTC
commit 1ef74943ce2f114c78b215af57c2ccc72ccdb0b7
Author: Paul Pluzhnikov <ppluzhnikov@google.com>
Date:   Thu Apr 25 11:08:31 2013 -0700

    Get rid of __STDC_FORMAT_MACROS, __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS

This went into glibc 2.18.