[cfe-dev] Clang C++0x extensions

Devchandra L Meetei dlmeetei at gmail.com
Thu Apr 28 22:43:29 PDT 2011


Does clang work correctly with gcc 4.4?
I was unable to compile even a hello world program using gcc 4.4 headers
with clang

On Thu, Apr 28, 2011 at 5:22 PM, Fletcher, John P
<j.p.fletcher at aston.ac.uk>wrote:

> Christopher
>
> Both -std=gnu++0x and -std=c++0x give errors in the GNU headers for gcc 4.4
> (the default version of gcc on my ubuntu system)
>
> fletcher at fletcher-desktop:~/test$ gcc --version
> gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
> Copyright (C) 2009 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> These errors may relate to c++0x things not yet implemented in Clang, or it
> could be that I need a different set of g++ headers.  I cannot tell.  Some
> problems are in <iostream> and some caused by clang/Basic/Version (clang
> 2.9)
>
> John
>
>
> fletcher at fletcher-desktop:~/test$ make testcpp_cpp0x
> /home/fletcher/LLVM/llvm/bin/clang++ -I/home/fletcher/LLVM/llvm/include
> -std=gnu++0x -DCLANG testcpp.cpp -otestcpp_cpp0x
> -L/home/fletcher/LLVM/llvm/lib -lclangBasic -lLLVMSupport -lpthread -ldl
> In file included from testcpp.cpp:47:
> In file included from /usr/include/c++/4.4/iostream:39:
> In file included from /usr/include/c++/4.4/ostream:39:
> In file included from /usr/include/c++/4.4/ios:39:
> In file included from /usr/include/c++/4.4/exception:148:
> /usr/include/c++/4.4/exception_ptr.h:143:13: error: unknown type name
>      'type_info'
>      const type_info*
>            ^
> In file included from testcpp.cpp:47:
> In file included from /usr/include/c++/4.4/iostream:39:
> In file included from /usr/include/c++/4.4/ostream:39:
> In file included from /usr/include/c++/4.4/ios:40:
> In file included from /usr/include/c++/4.4/bits/char_traits.h:40:
> In file included from /usr/include/c++/4.4/bits/stl_algobase.h:66:
> /usr/include/c++/4.4/bits/stl_pair.h:255:27: error: no matching function
> for
>      call to 'forward'
>        (std::forward<_T1>(__x), std::forward<_T2>(__y));
>                                 ^~~~~~~~~~~~~~~~~
> In file included from testcpp.cpp:49:
> In file included from
> /home/fletcher/LLVM/llvm/include/clang/Basic/Version.h:18:
> /home/fletcher/LLVM/llvm/include/llvm/ADT/StringRef.h:363:16: note: in
>      instantiation of function template specialization
> 'std::make_pair<const
>      llvm::StringRef &, llvm::StringRef>' requested here
>        return std::make_pair(*this, StringRef());
>               ^
> In file included from testcpp.cpp:47:
> In file included from /usr/include/c++/4.4/iostream:39:
> In file included from /usr/include/c++/4.4/ostream:39:
> In file included from /usr/include/c++/4.4/ios:40:
> In file included from /usr/include/c++/4.4/bits/char_traits.h:40:
> In file included from /usr/include/c++/4.4/bits/stl_algobase.h:66:
> In file included from /usr/include/c++/4.4/bits/stl_pair.h:60:
> /usr/include/c++/4.4/bits/move.h:51:5: note: candidate function [with _Tp =
>      llvm::StringRef] not viable: no known conversion from
> 'llvm::StringRef' to
>      'typename std::identity<StringRef>::type &&' (aka 'llvm::StringRef
> &&')
>      for 1st argument
>    forward(typename std::identity<_Tp>::type&& __t)
>    ^
> /usr/include/c++/4.4/bits/move.h:57:14: error: binding of reference to type
>      'typename std::remove_reference<StringRef &>::type'
>      (aka 'llvm::StringRef') to a value of type 'llvm::StringRef' drops
>      qualifiers
>    { return __t; }
>             ^~~
> In file included from testcpp.cpp:47:
> In file included from /usr/include/c++/4.4/iostream:39:
> In file included from /usr/include/c++/4.4/ostream:39:
> In file included from /usr/include/c++/4.4/ios:40:
> In file included from /usr/include/c++/4.4/bits/char_traits.h:40:
> In file included from /usr/include/c++/4.4/bits/stl_algobase.h:66:
> /usr/include/c++/4.4/bits/stl_pair.h:93:15: note: in instantiation of
> function
>      template specialization 'std::move<llvm::StringRef &>' requested here
>      : first(std::move(__p.first)),
>              ^
> In file included from testcpp.cpp:49:
> In file included from
> /home/fletcher/LLVM/llvm/include/clang/Basic/Version.h:18:
> /home/fletcher/LLVM/llvm/include/llvm/ADT/StringRef.h:363:16: note: in
>      instantiation of member function 'std::pair<llvm::StringRef,
>      llvm::StringRef>::pair' requested here
>        return std::make_pair(*this, StringRef());
>               ^
> In file included from testcpp.cpp:47:
> In file included from /usr/include/c++/4.4/iostream:39:
> In file included from /usr/include/c++/4.4/ostream:39:
> In file included from /usr/include/c++/4.4/ios:40:
> In file included from /usr/include/c++/4.4/bits/char_traits.h:40:
> In file included from /usr/include/c++/4.4/bits/stl_algobase.h:66:
> /usr/include/c++/4.4/bits/stl_pair.h:255:3: error: no matching function for
> call
>      to 'forward'
>        (std::forward<_T1>(__x), std::forward<_T2>(__y));
>         ^~~~~~~~~~~~~~~~~
> In file included from testcpp.cpp:49:
> In file included from
> /home/fletcher/LLVM/llvm/include/clang/Basic/Version.h:18:
> /home/fletcher/LLVM/llvm/include/llvm/ADT/StringRef.h:364:14: note: in
>      instantiation of function template specialization
>      'std::make_pair<llvm::StringRef, llvm::StringRef>' requested here
>      return std::make_pair(slice(0, Idx), slice(Idx+1, npos));
>             ^
> In file included from testcpp.cpp:47:
> In file included from /usr/include/c++/4.4/iostream:39:
> In file included from /usr/include/c++/4.4/ostream:39:
> In file included from /usr/include/c++/4.4/ios:40:
> In file included from /usr/include/c++/4.4/bits/char_traits.h:40:
> In file included from /usr/include/c++/4.4/bits/stl_algobase.h:66:
> In file included from /usr/include/c++/4.4/bits/stl_pair.h:60:
> /usr/include/c++/4.4/bits/move.h:51:5: note: candidate function [with _Tp =
>      llvm::StringRef] not viable: no known conversion from
> 'llvm::StringRef' to
>      'typename std::identity<StringRef>::type &&' (aka 'llvm::StringRef
> &&')
>      for 1st argument
>    forward(typename std::identity<_Tp>::type&& __t)
>    ^
> 4 errors generated.
> make: *** [testcpp_cpp0x] Error 1
>
> ________________________________________
> From: cfe-dev-bounces at cs.uiuc.edu [cfe-dev-bounces at cs.uiuc.edu] on behalf
> of Christopher Jefferson [chris at bubblescope.net]
> Sent: 27 April 2011 08:49
> To: Fletcher, John P
> Cc: cfe-dev Developers
> Subject: Re: [cfe-dev] Clang C++0x extensions
>
> On 26 Apr 2011, at 17:59, Fletcher, John P wrote:
>
> > Is there a specific command option to enable Clang C++0x extensions?  I
> have been looking through the manual and cannot find this.
>
> You probably want -std=gnu++0x.
>
> You can use -std=c++0x, but that disables gnu extensions. The default flag
> is  -std=gnu++03, and quite a bit of code (including last time I checked the
> standard header <cmath> on mac os x) won't compile in c++03 or c++0x mode.
>
> Chris
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110429/5c6899ea/attachment.html>


More information about the cfe-dev mailing list