public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57025] New: Solaris g++ defines __STDC_VERSION__=199901L
@ 2013-04-21 14:04 jdemeyer at cage dot ugent.be
  2013-04-21 14:47 ` [Bug c++/57025] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jdemeyer at cage dot ugent.be @ 2013-04-21 14:04 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57025

             Bug #: 57025
           Summary: Solaris g++ defines __STDC_VERSION__=199901L
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jdemeyer@cage.ugent.be
            Target: sparc-sun-solaris2.10


With GCC 4.7.2, when compiling C++ code in Solaris, the macro __STDC_VERSION__
is defined to be 199901L:

$ gcc -std=c++98 -x c++ /dev/null -E -dD |grep STDC
#define __STDC__ 1
#define __STDC_HOSTED__ 1
#define __STDC_VERSION__ 199901L

Despite this, the "restrict" keyword is not understood. This looks like a bug
to me: if the compiler defines __STDC_VERSION__=199901L, it should understand
C99 features like the "restrict" keyword. This only happens on Solaris as far
as I can tell.


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

* [Bug c++/57025] Solaris g++ defines __STDC_VERSION__=199901L
  2013-04-21 14:04 [Bug c++/57025] New: Solaris g++ defines __STDC_VERSION__=199901L jdemeyer at cage dot ugent.be
@ 2013-04-21 14:47 ` redi at gcc dot gnu.org
  2013-04-21 14:50 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2013-04-21 14:47 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57025

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-04-21 14:47:47 UTC ---
I think this is necessary to get the system libc to expose C99 library
features, it doesn't mean the C++ compiler supports language features that
aren't part of C++


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

* [Bug c++/57025] Solaris g++ defines __STDC_VERSION__=199901L
  2013-04-21 14:04 [Bug c++/57025] New: Solaris g++ defines __STDC_VERSION__=199901L jdemeyer at cage dot ugent.be
  2013-04-21 14:47 ` [Bug c++/57025] " redi at gcc dot gnu.org
@ 2013-04-21 14:50 ` redi at gcc dot gnu.org
  2013-04-21 14:53 ` jdemeyer at cage dot ugent.be
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2013-04-21 14:50 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57025

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-04-21 14:50:56 UTC ---
The C++ standard specifically says:

    __STDC_VERSION__
    Whether __STDC_VERSION__ is predefined and if so, what its value is, are
    implementation-defined.

So G++'s behaviour is not a bug, although we should update the docs which claim
it isn't defined:
http://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html


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

* [Bug c++/57025] Solaris g++ defines __STDC_VERSION__=199901L
  2013-04-21 14:04 [Bug c++/57025] New: Solaris g++ defines __STDC_VERSION__=199901L jdemeyer at cage dot ugent.be
  2013-04-21 14:47 ` [Bug c++/57025] " redi at gcc dot gnu.org
  2013-04-21 14:50 ` redi at gcc dot gnu.org
@ 2013-04-21 14:53 ` jdemeyer at cage dot ugent.be
  2013-04-21 15:09 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jdemeyer at cage dot ugent.be @ 2013-04-21 14:53 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57025

--- Comment #3 from Jeroen Demeyer <jdemeyer at cage dot ugent.be> 2013-04-21 14:53:26 UTC ---
(In reply to comment #1)
> I think this is necessary to get the system libc to expose C99 library
> features
Isn't this what fixincludes is for?

The problem is that some third party libraries might have code like
#if __STDC_VERSION__ >= 199901L
...code using "restrict"...
#endif

which breaks if this appears in C++ code.


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

* [Bug c++/57025] Solaris g++ defines __STDC_VERSION__=199901L
  2013-04-21 14:04 [Bug c++/57025] New: Solaris g++ defines __STDC_VERSION__=199901L jdemeyer at cage dot ugent.be
                   ` (2 preceding siblings ...)
  2013-04-21 14:53 ` jdemeyer at cage dot ugent.be
@ 2013-04-21 15:09 ` redi at gcc dot gnu.org
  2024-05-22 15:09 ` alan.coopersmith at oracle dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2013-04-21 15:09 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57025

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-04-21 15:09:48 UTC ---
Those libraries are incompatible with C++ then, the C++ standard allows
__STDC_VERSION to be defined by a C++ compiler.

The libraries could be fixed by also checking !defined(__cplusplus), or you
could 
#define restrict __restrict
before including them.


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

* [Bug c++/57025] Solaris g++ defines __STDC_VERSION__=199901L
  2013-04-21 14:04 [Bug c++/57025] New: Solaris g++ defines __STDC_VERSION__=199901L jdemeyer at cage dot ugent.be
                   ` (3 preceding siblings ...)
  2013-04-21 15:09 ` redi at gcc dot gnu.org
@ 2024-05-22 15:09 ` alan.coopersmith at oracle dot com
  2024-05-22 15:15 ` ro at CeBiTec dot Uni-Bielefeld.DE
  2024-05-22 20:27 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: alan.coopersmith at oracle dot com @ 2024-05-22 15:09 UTC (permalink / raw)
  To: gcc-bugs

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

Alan Coopersmith <alan.coopersmith at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alan.coopersmith at oracle dot com

--- Comment #11 from Alan Coopersmith <alan.coopersmith at oracle dot com> ---
While Solaris 11.3 support has been dropped from gcc now, Jonathan Perkins
from pkgsrc found that just removing the definition of __STDC_VERSION__
didn't work with some of the illumos headers:
https://github.com/jperkin/notes/blob/main/gcc-cpp-stdc/README.md

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

* [Bug c++/57025] Solaris g++ defines __STDC_VERSION__=199901L
  2013-04-21 14:04 [Bug c++/57025] New: Solaris g++ defines __STDC_VERSION__=199901L jdemeyer at cage dot ugent.be
                   ` (4 preceding siblings ...)
  2024-05-22 15:09 ` alan.coopersmith at oracle dot com
@ 2024-05-22 15:15 ` ro at CeBiTec dot Uni-Bielefeld.DE
  2024-05-22 20:27 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ro at CeBiTec dot Uni-Bielefeld.DE @ 2024-05-22 15:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot Uni-Bielefeld.DE> ---
> --- Comment #11 from Alan Coopersmith <alan.coopersmith at oracle dot com> ---
> While Solaris 11.3 support has been dropped from gcc now, Jonathan Perkins
> from pkgsrc found that just removing the definition of __STDC_VERSION__
> didn't work with some of the illumos headers:
> https://github.com/jperkin/notes/blob/main/gcc-cpp-stdc/README.md

Unfortunately, the Illumos guys have refused to cooperate with upstream
GCC and LLVM for years, never tried to upstream patches, perform
testing, report results or anything.  Unless they suddenly start
testing, analysis, and provide patches, I'm not willing to do their work
for them.  I simply don't have the time.

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

* [Bug c++/57025] Solaris g++ defines __STDC_VERSION__=199901L
  2013-04-21 14:04 [Bug c++/57025] New: Solaris g++ defines __STDC_VERSION__=199901L jdemeyer at cage dot ugent.be
                   ` (5 preceding siblings ...)
  2024-05-22 15:15 ` ro at CeBiTec dot Uni-Bielefeld.DE
@ 2024-05-22 20:27 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2024-05-22 20:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Alan Coopersmith from comment #11)
> While Solaris 11.3 support has been dropped from gcc now, Jonathan Perkins
> from pkgsrc found that just removing the definition of __STDC_VERSION__
> didn't work with some of the illumos headers:
> https://github.com/jperkin/notes/blob/main/gcc-cpp-stdc/README.md

So the illumos sys/feature_tests.h is using __STD_VERSION__ to mean "the
version of the C library to expose for the current language mode", whether that
language mode is a C language mode or a C++ one. And that's an entirely
reasonable use of it IMHO, and conforms to the C++ standard.

I stick by what I said in comment 4: code which assumes that __STDC_VERSION__
being defined implies a C compiler is being used is **broken C++ code**. There
is no compliance requirement why GCC should stop defining __STDC_VERSION__, and
there's a good reason to keep defining it if defining it is needed (or just
helpful) for a target's libc headers.

The Cython code quoted in the illumos notes should be fixed to check the
__cplusplus condition first, then if __cplusplus is not defined check
__STDC_VERSION__. It's just bad code.

N.B. since C++23 #include <stdatomic.h> works in C++ anyway:
https://wg21.link/P0943R6

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

end of thread, other threads:[~2024-05-22 20:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-21 14:04 [Bug c++/57025] New: Solaris g++ defines __STDC_VERSION__=199901L jdemeyer at cage dot ugent.be
2013-04-21 14:47 ` [Bug c++/57025] " redi at gcc dot gnu.org
2013-04-21 14:50 ` redi at gcc dot gnu.org
2013-04-21 14:53 ` jdemeyer at cage dot ugent.be
2013-04-21 15:09 ` redi at gcc dot gnu.org
2024-05-22 15:09 ` alan.coopersmith at oracle dot com
2024-05-22 15:15 ` ro at CeBiTec dot Uni-Bielefeld.DE
2024-05-22 20:27 ` redi at gcc dot gnu.org

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).