Bug 1318877

Summary: Per C11 and C++11, <stdint.h> should not look at __STDC_LIMIT_MACROS or __STDC_CONSTANT_MACROS
Product: Red Hat Enterprise Linux 7 Reporter: Frank Hirtz <fhirtz>
Component: glibcAssignee: Martin Sebor <msebor>
Status: CLOSED ERRATA QA Contact: Sergey Kolosov <skolosov>
Severity: low Docs Contact:
Priority: unspecified    
Version: 7.4CC: ashankar, codonell, cww, fweimer, jakub, law, mcermak, mnewsome, mpolacek, msebor, pfrankli, skolosov
Target Milestone: rcKeywords: Patch
Target Release: 7.4   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Definitions of certain macros in <stdint.h> were guarded by __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS, requiring the latter macros to be defined by a program in order for the former to be usable, contrary to the C11 and C++11 standards requirements. Consequence: The guarded macros were not usable unless the latter were defined. Fix: The guarding macros have been removed, and the macros previously guarded by them have been defined unconditionally. Result: More programs that strictly conform to the relevant standards are accommodated.
Story Points: ---
Clone Of:
: 1318878 (view as bug list) Environment:
Last Closed: 2017-08-01 18:06:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1298243, 1318878, 1390370    

Description Frank Hirtz 2016-03-18 03:01:00 UTC
Description of problem:

A client requested that we backport the following header fix:

<snip>
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.
</snip>

Reference:
https://sourceware.org/bugzilla/show_bug.cgi?id=15366

Version-Release number of selected component (if applicable):
glibc-headers-2.12-1.166.el6_7.7.x86_64

Comment 1 Carlos O'Donell 2016-03-20 14:38:26 UTC
The support for C11 and C++11 is only experimental in the RHEL 7 system compiler and runtimes, and there is no support for it in the RHEL 6 runtimes as far as I know.

Developer Toolset provides C11 and C++11 support in RHEL 7 and RHEL6, I'll switch the componet there and ask them for their opinion on how to fix this.

It might be that we conclude the changes are low enough risk in RHEL6 that we might change the core runtime headers, but my feeling is that this may be unacceptable as RHEL6 is now in Production Phase 2. The fix will therefore have to be contained entirely in Developer Toolset.

Comment 4 Carlos O'Donell 2016-03-29 16:33:35 UTC
The changes are unacceptable from a risk perspective for RHEL6 Production Phase 2.

The changes are acceptable for glibc in RHEL7, so we'll look at these for rhel-7.4. This would enable the use of DTS for compiling C11, but not the system compiler.

Comment 5 Jakub Jelinek 2016-03-29 16:57:26 UTC
I meant rather than say removing the
-/* 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
-
stuff change it to:
/* 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 || __GNUC_PREREQ (5, 0)
or something similar.  That should not be that risky even for older RHELs.

Comment 6 Carlos O'Donell 2016-03-29 17:13:12 UTC
(In reply to Jakub Jelinek from comment #5)
> I meant rather than say removing the
> -/* 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
> -
> stuff change it to:
> /* 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 || __GNUC_PREREQ (5,
> 0)
> or something similar.  That should not be that risky even for older RHELs.

That might be workable for older RHEL. Again my worry is that there are people already using gcc 5.x on RHEL6, perhaps their own compiler, and changing glibc would change the behaviour that they are seeing from the core runtimes. In a production phase 2 release like RHEL 6.9 we don't want to change anything that anyone might already be expecting to behave a certain way. While in RHEL 7.3 and 7.4 we have much more tolerance to this kind of change.

Comment 7 Florian Weimer 2016-11-24 18:18:18 UTC
Upstream:

commit 1ef74943ce2f114c78b215af57c2ccc72ccdb0b7
Author: Paul Pluzhnikov <ppluzhnikov>
Date:   Thu Apr 25 11:08:31 2013 -0700

    Get rid of __STDC_FORMAT_MACROS, __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS

Comment 14 errata-xmlrpc 2017-08-01 18:06:55 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2017:1916