[Bug c++/67256] New: [C++11] Global scope contaminated with symbols from mathcalls.h

2015-08-18 Thread michal.fita at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67256

Bug ID: 67256
   Summary: [C++11] Global scope contaminated with symbols from
mathcalls.h
   Product: gcc
   Version: 4.9.2
Status: UNCONFIRMED
  Severity: major
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: michal.fita at gmail dot com
  Target Milestone: ---

Created attachment 36198
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36198&action=edit
The test code.

I have problem with GCC 4.9.2 on Jessie, where with -std=c++11 I cannot compile
my code. I attached the test example which compiles with:

  g++ -o test g++mathcalls-error.cpp

But doesn't compile with:

  g++ -o test -std=c++11 g++mathcalls-error.cpp

Producing following errors:

g++mathcalls-error.cpp:7:15: error: ‘namespace log { }’ redeclared as different
kind of symbol
 namespace log {
   ^
In file included from /usr/include/features.h:374:0,
 from
/usr/include/x86_64-linux-gnu/c++/4.9/bits/os_defines.h:39,
 from
/usr/include/x86_64-linux-gnu/c++/4.9/bits/c++config.h:430,
 from /usr/include/c++/4.9/utility:68,
 from /usr/include/c++/4.9/algorithm:60,
 from g++mathcalls-error.cpp:2:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:109:1: note: previous
declaration ‘double log(double)’
 __MATHCALL (log,, (_Mdouble_ __x));
 ^
g++mathcalls-error.cpp:19:15: error: ‘namespace sin { }’ redeclared as
different kind of symbol
 namespace sin {
   ^
In file included from /usr/include/features.h:374:0,
 from
/usr/include/x86_64-linux-gnu/c++/4.9/bits/os_defines.h:39,
 from
/usr/include/x86_64-linux-gnu/c++/4.9/bits/c++config.h:430,
 from /usr/include/c++/4.9/utility:68,
 from /usr/include/c++/4.9/algorithm:60,
 from g++mathcalls-error.cpp:2:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:65:1: note: previous declaration
‘double sin(double)’
 __MATHCALL (sin,, (_Mdouble_ __x));
 ^
g++mathcalls-error.cpp: In function ‘int main()’:
g++mathcalls-error.cpp:28:5: error: ‘log’ is not a class, namespace, or
enumeration
 log::info("Test %s", "sinner");
 ^
g++mathcalls-error.cpp:29:5: error: ‘sin’ is not a class, namespace, or
enumeration
 sin::cardinal(666);
 ^

So, this may not be bug inside the compiler (however studies of inclusion chain
leads nowhere), but with the standard set of headers. This cause symbols
related to math functions be present in global scope instead of std namespace.

This effectively block us from using namespaces like "log" or "sin" in our huge
codebase if we want to move toward C++11 standard.

[Bug libstdc++/67256] [C++11] Global scope contaminated with symbols from mathcalls.h

2015-08-18 Thread michal.fita at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67256

--- Comment #3 from Michał Fita  ---
Contrary to my expectations #include  doesn't work either. I would
expect these not declared in global if standard says unspecified, as my logic
whisper that would be more C++ way. I understand then I shouldn't expect to get
this fixed as removing these symbols from global scope would break existing
code?

Interesting thing about declaration in mathcalls.h is that they're surrounded
by _Mdouble_BEGIN_NAMESPACE and _Mdouble_END_NAMESPACE macros, which seem empty
when included from cmath (to my surprise that one redefines all functions in
std on top of what is in math.h). Whether these are empty or not the presence
of _GLIBCPP_USE_NAMESPACES decides.

Now I see it has been mindfully done with purpose: 
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6257
- http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#456

Another point to the C++ list on the side "hate".

[Bug c++/77388] Reference to a packed structure member

2016-08-26 Thread michal.fita at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77388

Michał Fita  changed:

   What|Removed |Added

 CC||michal.fita at gmail dot com

--- Comment #1 from Michał Fita  ---
Nicely narrows Andre, Thanks. Added myself to CC to track progress.