Bug 69721 - [6 Regression] math.h is broken, unqualified use of __is_integer
Summary: [6 Regression] math.h is broken, unqualified use of __is_integer
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: 6.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-08 11:36 UTC by Richard Biener
Modified: 2016-02-08 12:07 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2016-02-08 11:36:33 UTC
I see ffado build fail with

[  127s] g++ -o src/libutil/serialize_libxml.os -c -m64 -fmessage-length=0 -grecord-gcc-switches -Wall -fstack-protector -funwind-tables -fasynchronous-unwind-tables -Wno-error=misleading-indentation -Wno-error=narrowing -Wno-error=nonnull -Wno-error=unused-const-variable -g -fno-strict-aliasing -ggdb -Wno-deprecated-declarations -O2 -fPIC -mmmx -mfpmath=sse -msse -msse2 -mssse3 -msse4.1 -msse4.2 -fomit-frame-pointer -ffast-math -funroll-loops -fPIC -D_FORTIFY_SOURCE=2 -DDEBUG_MESSAGES -DENABLE_BEBOB -DENABLE_FIREWORKS -DENABLE_OXFORD -DENABLE_MOTU -DENABLE_DICE -DENABLE_METRIC_HALO -DENABLE_RME -DENABLE_DIGIDESIGN -DENABLE_BOUNCE -DENABLE_GENERICAVC -I. -Isrc -I/usr/include/libxml++-2.6 -I/usr/lib64/libxml++-2.6/include -I/usr/include/libxml2 -I/usr/include/glibmm-2.4 -I/usr/lib64/glibmm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sigc++-2.0 -I/usr/lib64/sigc++-2.0/include src/libutil/serialize_libxml.cpp
[  127s] In file included from /usr/include/c++/6/math.h:36:0,
[  127s]                  from src/libutil/TimestampedBuffer.cpp:182:
[  127s] /usr/include/c++/6/cmath:101:37: error: '__is_integer' was not declared in this scope
[  127s]      typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
[  127s]                                      ^~~~~~~~~~~~

noting that __is_integer is not std:: qualified in cmath.

Note that ffado includes math.h, not cmath and does so from within a namespace.

Doing that in a (too simple) testcase produces

In file included from /usr/include/c++/6/math.h:36:0,
                 from t.C:2:
/usr/include/c++/6/cmath:106:11: error: ‘::acos’ has not been declared
   using ::acos;
           ^~~~
...

instead of the above.

namespace Foo {
#include <math.h>
}

this testcase works fine in GCC 5.
Comment 1 Jakub Jelinek 2016-02-08 11:49:54 UTC
This looks invalid to me.
Comment 2 Jonathan Wakely 2016-02-08 12:01:32 UTC
Definitely invalid. It might have worked before because <math.h> only declared extern "C" functions, which don't include namespaces in their mangled names, but the code always had undefined behaviour.

Now that <math.h> is implemented by including <cmath> (which defines extern "C++" functions where namespaces matter) the undefined code stops working. That's the problem with undefined code that just happens to work today, it might stop working at any time.
Comment 3 Jonathan Wakely 2016-02-08 12:07:04 UTC
17.6.2.2 [using.headers]

"A translation unit shall include a header only outside of any declaration or definition,"

That includes namespace declarations ("header" in the standard means a standard header, this rule doesn't apply to non-standard include files).