Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility between clang++ 14 and libstdc++ 12 #54463

Open
berolinux opened this issue Mar 20, 2022 · 7 comments
Open

Incompatibility between clang++ 14 and libstdc++ 12 #54463

berolinux opened this issue Mar 20, 2022 · 7 comments
Labels
clang Clang issues not falling into any other category

Comments

@berolinux
Copy link

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.
@EugeneZelenko EugeneZelenko added libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. and removed new issue labels Mar 20, 2022
@philnik777
Copy link
Contributor

This looks like a clang issue and not a libc++ issue to me. Am I correct @berolinux?

@berolinux
Copy link
Author

yes, libc++ isn't involved, this happens when using libstdc++ from gcc 12.
It's also only triggered with -fgnuc-version set to something newer than 5.0.

clang doesn't implement a language extension implemented in gcc and icc, which libstdc++ assumes is there if GNUC >= 5

@philnik777 philnik777 added clang Clang issues not falling into any other category and removed libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. labels Mar 20, 2022
@philnik777
Copy link
Contributor

I don't know exactly which label should be used for clang. I hope someone who knows it adds the correct one.

@ms178
Copy link

ms178 commented Mar 21, 2022

Just for additional context, the gcc folks implemented a workaround on their side for this recently: gcc-mirror/gcc@e63ac86

@efriedma-quic
Copy link
Collaborator

Could you give some context about why you're using -fgnuc-version=?

@berolinux
Copy link
Author

Workaround for legacy cruft doing the likes of

#if __GNUC__ > (some number between 5 and 12)
// do something same that would work with any fairly recent compiler
#else
// do something else that is much slower but happens to work with gcc 4.x or other compilers from that time frame
#endif

gcc 5 was released in 2015 -- lots of progress has been made in both gcc and clang since then. And a lot of things never assumed there would be other compilers than gcc, so they use #if __GNUC__ > ... even where they should be using __cplusplus or something.

@efriedma-quic
Copy link
Collaborator

I think the last time the default was discussed was https://discourse.llvm.org/t/whats-the-rationale-to-continue-declare-compatibility-with-gcc-4-2-1/52530 . See also https://discourse.llvm.org/t/rfc-bump-up-clangs-gnuc-minor/23084 ; in particular, clang still doesn't implement __builtin_va_arg_pack(), which is probably still a blocker for messing with the default here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

No branches or pull requests

5 participants