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

clang++ --std=gnu++11 fails to compile <iostream> #13902

Closed
llvmbot opened this issue Aug 6, 2012 · 9 comments
Closed

clang++ --std=gnu++11 fails to compile <iostream> #13902

llvmbot opened this issue Aug 6, 2012 · 9 comments
Labels
bugzilla Issues migrated from bugzilla c++11

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 6, 2012

Bugzilla Link 13530
Resolution FIXED
Resolved on Sep 12, 2017 01:38
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@ht990332,@tkremenek,@llunak,@nlewycky,@nico,@paulmenzel,@zygoloid

Extended Description

clang fails compiling a hello world program when using the --std=gnu+11 option:

cat test.cpp

#include

int main() {
std::cout << "Hello, world!" << std::endl;
}

clang++ test.cpp -o test -std=gnu++11

In file included from test.cpp:1:
In file included from /usr/lib/gcc/i686-redhat-linux/4.7.0/../../../../include/c++/4.7.0/iostream:39:
In file included from /usr/lib/gcc/i686-redhat-linux/4.7.0/../../../../include/c++/4.7.0/ostream:39:
In file included from /usr/lib/gcc/i686-redhat-linux/4.7.0/../../../../include/c++/4.7.0/ios:40:
In file included from /usr/lib/gcc/i686-redhat-linux/4.7.0/../../../../include/c++/4.7.0/bits/char_traits.h:40:
In file included from /usr/lib/gcc/i686-redhat-linux/4.7.0/../../../../include/c++/4.7.0/bits/stl_algobase.h:65:
In file included from /usr/lib/gcc/i686-redhat-linux/4.7.0/../../../../include/c++/4.7.0/bits/stl_pair.h:61:
In file included from /usr/lib/gcc/i686-redhat-linux/4.7.0/../../../../include/c++/4.7.0/bits/move.h:57:
/usr/lib/gcc/i686-redhat-linux/4.7.0/../../../../include/c++/4.7.0/type_traits:256:39: error: use of undeclared identifier '__float128'
struct __is_floating_point_helper<__float128>
^
1 error generated.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Aug 6, 2012

Sorry, I forgot to mention the version im running :

clang --version

clang version 3.2 (trunk 161295)
Target: i386-pc-linux-gnu
Thread model: posix

@DougGregor
Copy link
Contributor

Looks like GCC 4.7 introduced more builtins that Clang will need to implement.

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Aug 6, 2012

Clang doesn't support the __float128 type. Here are some workarounds:

  1. build with -D__STRICT_ANSI__
  2. edit bits/c++config.h (somewhere inside /usr/include/c++/4.7.0) so it doesn't define _GLIBCXX_USE_FLOAT128
  3. configure libstdc++ with clang instead of gcc
  4. add 'struct __float128;' before you include any STL header

Experimentation with the LLVM fp128 and ppc_fp128 types a few months ago indicated that we have essentially no backends which support __float128 yet, so if we want to work around this directly in Clang, I think option (4) is probably the best way (add a __float128 type which is always incomplete).

@DougGregor
Copy link
Contributor

Clang doesn't support the __float128 type. Here are some workarounds:

  1. build with -D__STRICT_ANSI__
  2. edit bits/c++config.h (somewhere inside /usr/include/c++/4.7.0) so it
    doesn't define _GLIBCXX_USE_FLOAT128
  3. configure libstdc++ with clang instead of gcc
  4. add 'struct __float128;' before you include any STL header

Experimentation with the LLVM fp128 and ppc_fp128 types a few months ago
indicated that we have essentially no backends which support __float128 yet, so
if we want to work around this directly in Clang, I think option (4) is
probably the best way (add a __float128 type which is always incomplete).

I could live with (4), although I'd prefer that we be lazy about it rather than injecting it into every translation unit.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Dec 27, 2012

Experimentation with the LLVM fp128 and ppc_fp128 types a few months ago
indicated that we have essentially no backends which support __float128 yet

Doesnt that imply that this 'bug' should be turned into an 'enahancement request' for those backends ?

@llunak
Copy link
Collaborator

llunak commented Jun 19, 2013

One more possible workaround (and IMO the simplest for users of Clang) is to add -D__float128=void to CXXFLAGS. It doesn't require libstdc++ modifications, it doesn't require ansi mode, it's enough to make the listdc++ header pass and (hopefully) it'll still fail with any other accidental use of __float128 elsewhere.

@nico
Copy link
Contributor

nico commented Jun 20, 2013

Patch attempt for the approach in comments #​3 and #​4: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130617/082233.html

comment #​6: Since libstdc++ marks __float128 as a floating point type, you might end up with libstdc++ thinking that void is a floating type with that define (?).

@nico
Copy link
Contributor

nico commented Jun 20, 2013

Fixed in r184476.

@llunak
Copy link
Collaborator

llunak commented Jun 21, 2013

comment #​6: Since libstdc++ marks __float128 as a floating point type, you
might end up with libstdc++ thinking that void is a floating type with that
define (?).

It's a workaround, and I think you can't do better without modifying libstdc++ (or clang). In practice it seems to work, the whole of LibreOffice works fine that way.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++11
Projects
None yet
Development

No branches or pull requests

4 participants