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

Fletcher, John P j.p.fletcher at aston.ac.uk
Thu Apr 28 09:23:31 PDT 2011


I don't see this error.  I only see errors when I define -std=gnu++0x or -std=c++0x with clang 2.9.

For me, Clang without the flags works, and also g++ with -std=gnu++0x

It looks as though some of the errors are addressed in this patch file: libstdc++4.4-clang0x.patch
but I have not seen anything there about type_info, the first of the errors I report.

John

________________________________
From: cfe-dev-bounces at cs.uiuc.edu [cfe-dev-bounces at cs.uiuc.edu] on behalf of İsmail Dönmez [ismail at namtrac.org]
Sent: 28 April 2011 13:54
To: Vassil Vassilev
Cc: Fletcher, John P; cfe-dev Developers
Subject: Re: [cfe-dev] Clang C++0x extensions

This is a recent regression, see http://llvm.org/bugs/show_bug.cgi?id=9804

ismail

On Thu, Apr 28, 2011 at 2:43 PM, Vassil Vassilev <vasil.georgiev.vasilev at cern.ch<mailto:vasil.georgiev.vasilev at cern.ch>> wrote:
Hi,
  Interesting... I don't think it is only for 0x... I have the same
problem:
uname -a
Linux PCPHSFT79 2.6.32-31-generic #61-Ubuntu SMP Fri Apr 8 18:25:51 UTC
2011 x86_64 GNU/Linux

cat clang_fails.cxx
#include <string>

extern "C" int printf(const char* fmt, ...);

int main () {
  std::string a = "a";
  printf("%s\n", a.c_str());
  return 0;
}

../Debug+Asserts/bin/clang clang_fails.cxx
In file included from clang_fails.cxx:1:
In file included from /usr/include/c++/4.4/string:41:
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:65:
/usr/include/c++/4.4/ext/numeric_traits.h:60:25: error: expected member
name or ';' after declaration specifiers
      static const bool __is_signed = __glibcxx_signed(_Value);
      ~~~~~~~~~~~~~~~~~ ^
/usr/include/c++/4.4/ext/numeric_traits.h:71:50: error: expected
unqualified-id
    const bool __numeric_traits_integer<_Value>::__is_signed;
                                                 ^
/usr/include/c++/4.4/ext/numeric_traits.h:103:25: error: expected member
name or ';' after declaration specifiers
      static const bool __is_signed = true;
      ~~~~~~~~~~~~~~~~~ ^
/usr/include/c++/4.4/ext/numeric_traits.h:112:51: error: expected
unqualified-id
    const bool __numeric_traits_floating<_Value>::__is_signed;
                                                  ^
In file included from clang_fails.cxx:1:
In file included from /usr/include/c++/4.4/string:41:
In file included from /usr/include/c++/4.4/bits/char_traits.h:40:
/usr/include/c++/4.4/bits/stl_algobase.h:925:49: error: expected
unqualified-id
&& !__gnu_cxx::__numeric_traits<_ValueType1>::__is_signed
                                                       ^
/usr/include/c++/4.4/bits/stl_algobase.h:930:45: error: non-type
template argument of type 'const bool' is not an integral constant
expression
      return std::__lexicographical_compare<__simple>::__lc(__first1,
__last1,
                                            ^~~~~~~~
6 errors generated.

I don't think this is expected. Is it?

Vassil

On 04/28/2011 01:52 PM, Fletcher, John P 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<mailto:cfe-dev-bounces at cs.uiuc.edu> [cfe-dev-bounces at cs.uiuc.edu<mailto:cfe-dev-bounces at cs.uiuc.edu>] on behalf of Christopher Jefferson [chris at bubblescope.net<mailto: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<mailto: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<mailto: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<mailto:cfe-dev at cs.uiuc.edu>
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list