public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/104990] New: [12 Regression] std::get_time is incompatible with clang 14
@ 2022-03-20 11:04 bero at lindev dot ch
  2022-03-20 12:41 ` [Bug libstdc++/104990] " jakub at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: bero at lindev dot ch @ 2022-03-20 11:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104990
           Summary: [12 Regression] std::get_time is incompatible with
                    clang 14
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bero at lindev dot ch
  Target Milestone: ---

This sample code:


#include <iomanip>
#include <iostream>

int main(int argc, char **argv) {
        std::tm tm = {};
        std::stringstream ss("2022-03-18 01:02:03");
        ss >>std::get_time(&tm, "%Y-%m-%d %H:%M:%S");
        std::cout << std::asctime(&tm);
}


works perfectly when built with gcc 12.0, or when built with clang 14 using
libc++ or libstdc++ versions prior to 12.0 -- but when using clang with
libstdc++ 12.0 (20220313 snapshot), it results in

In file included from test.cc:1:
In file included from
/usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/12.0.0/../../../../include/c++/12.0.0/iomanip:43:
In file included from
/usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/12.0.0/../../../../include/c++/12.0.0/locale:41:
In file included from
/usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/locale_facets_nonio.h:2069:
/usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/locale_facets_nonio.tcc:1477:18:
error: reference to non-static member function must be called
      if ((void*)(this->*(&time_get::do_get)) == (void*)(&time_get::do_get))
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-openmandriva-linux-gnu/12.0.0/../../../../include/c++/12.0.0/iomanip:433:20:
note: in instantiation of member function 'std::time_get<char>::get' requested
here
              __mg.get(_Iter(__is.rdbuf()), _Iter(), __is,
                   ^
test.cc:7:5: note: in instantiation of function template specialization
'std::operator>><char, std::char_traits<char>>' requested here
        ss >>std::get_time(&tm, "%Y-%m-%d %H:%M:%S");
           ^
1 error generated.

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

* [Bug libstdc++/104990] [12 Regression] std::get_time is incompatible with clang 14
  2022-03-20 11:04 [Bug libstdc++/104990] New: [12 Regression] std::get_time is incompatible with clang 14 bero at lindev dot ch
@ 2022-03-20 12:41 ` jakub at gcc dot gnu.org
  2022-03-20 13:11 ` bero at lindev dot ch
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-20 12:41 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
How is that possible?
This code is guarded with
#if __GNUC__ >= 5
because it is using a GCC extension which ICC also supports.
AFAIK clang predefines __GNUC__ as 4 and __GNUC_MINOR__ as 2.

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

* [Bug libstdc++/104990] [12 Regression] std::get_time is incompatible with clang 14
  2022-03-20 11:04 [Bug libstdc++/104990] New: [12 Regression] std::get_time is incompatible with clang 14 bero at lindev dot ch
  2022-03-20 12:41 ` [Bug libstdc++/104990] " jakub at gcc dot gnu.org
@ 2022-03-20 13:11 ` bero at lindev dot ch
  2022-03-21  0:51 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: bero at lindev dot ch @ 2022-03-20 13:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Bernhard Rosenkraenzer <bero at lindev dot ch> ---
clang's __GNUC__ defines depend on a command line -fgnuc-version=

This showed up with -fgnuc-version=11.2 on the command line to work around code
doing broken things like in the particular code being compiled.

#if __GNUC__ > 5
// do something sane
#else
// insane workaround because gcc 4.x was missing features
// both gcc and clang have these days
#endif

So probably only few people will run into this -- but it's probably worth
changing

#if __GNUC__ >= 5

to

#if __GNUC__ >= 5 && !defined(__clang__)

(or alternatively adding the extension to clang).

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

* [Bug libstdc++/104990] [12 Regression] std::get_time is incompatible with clang 14
  2022-03-20 11:04 [Bug libstdc++/104990] New: [12 Regression] std::get_time is incompatible with clang 14 bero at lindev dot ch
  2022-03-20 12:41 ` [Bug libstdc++/104990] " jakub at gcc dot gnu.org
  2022-03-20 13:11 ` bero at lindev dot ch
@ 2022-03-21  0:51 ` pinskia at gcc dot gnu.org
  2022-03-21  0:53 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-03-21  0:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>This showed up with -fgnuc-version=11.2

Well then this is a bug in clang for allowing this really. libstdc++ uses
extensions based on the GNUC++ version and you specify that it was the wrong
version of GCC.

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

* [Bug libstdc++/104990] [12 Regression] std::get_time is incompatible with clang 14
  2022-03-20 11:04 [Bug libstdc++/104990] New: [12 Regression] std::get_time is incompatible with clang 14 bero at lindev dot ch
                   ` (2 preceding siblings ...)
  2022-03-21  0:51 ` pinskia at gcc dot gnu.org
@ 2022-03-21  0:53 ` pinskia at gcc dot gnu.org
  2022-03-21  8:56 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-03-21  0:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>This showed up with -fgnuc-version=11.2 on the command line to work around code doing broken things like in the particular code being compiled.

Why not fix that code instead of having libstdc++ workaround a feature not
existing in clang when you specify the version.

In fact I think it is bad that __GNUC__ is even defined for clang in the first
place.

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

* [Bug libstdc++/104990] [12 Regression] std::get_time is incompatible with clang 14
  2022-03-20 11:04 [Bug libstdc++/104990] New: [12 Regression] std::get_time is incompatible with clang 14 bero at lindev dot ch
                   ` (3 preceding siblings ...)
  2022-03-21  0:53 ` pinskia at gcc dot gnu.org
@ 2022-03-21  8:56 ` rguenth at gcc dot gnu.org
  2022-03-21  9:38 ` redi at gcc dot gnu.org
  2022-03-21 10:03 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-03-21  8:56 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
   Target Milestone|---                         |12.0
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
A bug in clang / user error.

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

* [Bug libstdc++/104990] [12 Regression] std::get_time is incompatible with clang 14
  2022-03-20 11:04 [Bug libstdc++/104990] New: [12 Regression] std::get_time is incompatible with clang 14 bero at lindev dot ch
                   ` (4 preceding siblings ...)
  2022-03-21  8:56 ` rguenth at gcc dot gnu.org
@ 2022-03-21  9:38 ` redi at gcc dot gnu.org
  2022-03-21 10:03 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-21  9:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
FWIW the misfeature was added by https://reviews.llvm.org/D68055

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

* [Bug libstdc++/104990] [12 Regression] std::get_time is incompatible with clang 14
  2022-03-20 11:04 [Bug libstdc++/104990] New: [12 Regression] std::get_time is incompatible with clang 14 bero at lindev dot ch
                   ` (5 preceding siblings ...)
  2022-03-21  9:38 ` redi at gcc dot gnu.org
@ 2022-03-21 10:03 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-21 10:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:e63ac860afe816fef6b86bee6e47980e1351213c

commit r12-7734-ge63ac860afe816fef6b86bee6e47980e1351213c
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Mar 21 11:02:04 2022 +0100

    libstdc++: Work around clang misdesign in time_get<>::get [PR104990]

    Apparently clang has a -fgnuc-version= option which allows it to pretend
    it is any GCC version the user likes.  It is already bad that it claims to
    be GCC 4.2 compatible by default when it is not (various unimplemented
    extensions at least), but this option is a horrible idea.

    Anyway, this patch adds a hack for it.

    2022-03-21  Jakub Jelinek  <jakub@redhat.com>

            PR libstdc++/104990
            * include/bits/locale_facets_nonio.tcc (get): Don't check if do_get
            isn't overloaded if __clang__ is defined.

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

end of thread, other threads:[~2022-03-21 10:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-20 11:04 [Bug libstdc++/104990] New: [12 Regression] std::get_time is incompatible with clang 14 bero at lindev dot ch
2022-03-20 12:41 ` [Bug libstdc++/104990] " jakub at gcc dot gnu.org
2022-03-20 13:11 ` bero at lindev dot ch
2022-03-21  0:51 ` pinskia at gcc dot gnu.org
2022-03-21  0:53 ` pinskia at gcc dot gnu.org
2022-03-21  8:56 ` rguenth at gcc dot gnu.org
2022-03-21  9:38 ` redi at gcc dot gnu.org
2022-03-21 10:03 ` cvs-commit 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).