public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/25214] ctype.h performance (and potentially behavior) depends on include order
       [not found] <bug-25214-131@http.sourceware.org/bugzilla/>
@ 2021-04-05 13:18 ` andysem at mail dot ru
  2021-04-05 13:27 ` andysem at mail dot ru
  2021-04-17  0:42 ` travis.downs at gmail dot com
  2 siblings, 0 replies; 3+ messages in thread
From: andysem at mail dot ru @ 2021-04-05 13:18 UTC (permalink / raw)
  To: glibc-bugs

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

andysem at mail dot ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andysem at mail dot ru

--- Comment #4 from andysem at mail dot ru ---
(In reply to Travis Downs from comment #3)
> Here's an example that shows that <stdlib.h> defines __NO_CTYPE when
> compiled in C++:
> 
> https://godbolt.org/z/y6Quxs
> 
> In C it is not defined.

gcc ships C library header overrides, including stdlib.h, so when you're
including stdlib.h from a C++ program you're getting its C++ version.
Eventually it includes the C stdlib.h, but before that it may define necessary
config macros and do other stuff necessary for compliance with C++.

You can see all includes, with paths, in preprocessed output by adding -P to
gcc command line. On my system with gcc 10 your test program shows these
includes, in that order, among the first lines of the preprocessed output:

/usr/include/c++/10/stdlib.h
/usr/include/c++/10/cstdlib
/usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h
/usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h

and os_defines.h defines __NO_CTYPE.

I would think that the macro should be either defined or not in C++ regardless
of the header you include first. Otherwise there is potential for ODR
violations, which result in nasty bugs. If this isn't the case, you should
probably report a libstdc++ bug, describing the sequence of includes and the
effects.

Separately, I think it is worth requesting libstdc++ to implement a similar
optimization that glibc does so that the locale functions are inlined, when
possible. This could even reuse glibc implementation by juggling pragma
push_macro/pop_macro
(https://gcc.gnu.org/onlinedocs/gcc/Push_002fPop-Macro-Pragmas.html).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/25214] ctype.h performance (and potentially behavior) depends on include order
       [not found] <bug-25214-131@http.sourceware.org/bugzilla/>
  2021-04-05 13:18 ` [Bug libc/25214] ctype.h performance (and potentially behavior) depends on include order andysem at mail dot ru
@ 2021-04-05 13:27 ` andysem at mail dot ru
  2021-04-17  0:42 ` travis.downs at gmail dot com
  2 siblings, 0 replies; 3+ messages in thread
From: andysem at mail dot ru @ 2021-04-05 13:27 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #5 from andysem at mail dot ru ---
Sorry, the command line argument is -E.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/25214] ctype.h performance (and potentially behavior) depends on include order
       [not found] <bug-25214-131@http.sourceware.org/bugzilla/>
  2021-04-05 13:18 ` [Bug libc/25214] ctype.h performance (and potentially behavior) depends on include order andysem at mail dot ru
  2021-04-05 13:27 ` andysem at mail dot ru
@ 2021-04-17  0:42 ` travis.downs at gmail dot com
  2 siblings, 0 replies; 3+ messages in thread
From: travis.downs at gmail dot com @ 2021-04-17  0:42 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #6 from Travis Downs <travis.downs at gmail dot com> ---
Thanks Andrey, I've filed this bug against libstdc++:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100128

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2021-04-17  0:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-25214-131@http.sourceware.org/bugzilla/>
2021-04-05 13:18 ` [Bug libc/25214] ctype.h performance (and potentially behavior) depends on include order andysem at mail dot ru
2021-04-05 13:27 ` andysem at mail dot ru
2021-04-17  0:42 ` travis.downs at gmail 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).