[cfe-dev] Help: compiler's error using -stdlib=libc++ with clang++-3.8

zosrothko via cfe-dev cfe-dev at lists.llvm.org
Sat Jul 22 00:54:03 PDT 2017


Hello CFE list

Sorry to post again this post, but I am really stacked on this problem.

I have an issue compiling a small c++ program with clang++-3.8 on Ubuntu 
trusty

Using the joined c++ program bug.cpp,

  * clang++-3.8 -std=c++11 bug.cpp compiles fine while
  * clang++-3.8 -std=c++11 -stdlib=libc++ bug.cpp produces invalid
    compile errors.


What could be the problem and how can it be solved?

TIA

fandre at ubuntu-trusty-64:~/clang$ uname -a
Linux ubuntu-trusty-64 4.4.0-83-generic #106~14.04.1-Ubuntu SMP Mon Jun 
26 18:10:19 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
fandre at ubuntu-trusty-64:~/clang$ clang++-3.8 --version
clang version 3.8.0-2ubuntu3~trusty4 (tags/RELEASE_380/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Below is the console log

fandre at ubuntu-trusty-64:~/clang$ clang++-3.8 -std=c++11 bug.cpp
fandre at ubuntu-trusty-64:~/clang$ clang++-3.8 -std=c++11 -stdlib=libc++ 
bug.cpp
bug.cpp:56:88: error: 'Header' does not refer to a value
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, code) == 0x01)>)> poco_...
^
bug.cpp:45:9: note: declared here
  struct Header
         ^
bug.cpp:56:96: error: use of undeclared identifier 'code'
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, code) == 0x01)>)> poco_...
^
bug.cpp:56:111: error: type name requires a specifier or qualifier
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, code) == 0x01)>)> poco_...
^
bug.cpp:57:88: error: 'Header' does not refer to a value
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, checksum) == 0x02)>)> p...
^
bug.cpp:45:9: note: declared here
  struct Header
         ^
bug.cpp:57:96: error: use of undeclared identifier 'checksum'
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, checksum) == 0x02)>)> p...
^
bug.cpp:57:115: error: type name requires a specifier or qualifier
...poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, checksum) == 0x02)>)> poco_stati...
^
bug.cpp:58:88: error: 'Header' does not refer to a value
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, id) == 0x04)>)> poco_st...
^
bug.cpp:45:9: note: declared here
  struct Header
         ^
bug.cpp:58:96: error: use of undeclared identifier 'id'
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, id) == 0x04)>)> poco_st...
^
bug.cpp:58:109: error: type name requires a specifier or qualifier
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, id) == 0x04)>)> poco_st...
^
bug.cpp:59:88: error: 'Header' does not refer to a value
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, seq) == 0x06)>)> poco_s...
^
bug.cpp:45:9: note: declared here
  struct Header
         ^
bug.cpp:59:96: error: use of undeclared identifier 'seq'
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, seq) == 0x06)>)> poco_s...
^
bug.cpp:59:110: error: type name requires a specifier or qualifier
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, seq) == 0x06)>)> poco_s...
^
12 errors generated.
fandre at ubuntu-trusty-64:~/clang$ cp bug.cpp ../shared
fandre at ubuntu-trusty-64:~/clang$ clang++-3.8 -std=c++11 bug.cpp
fandre at ubuntu-trusty-64:~/clang$ clang++-3.8 -std=c++11 -stdlib=libc++ 
bug.cpp
bug.cpp:56:88: error: 'Header' does not refer to a value
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, code) == 0x01)>)> poco_...
^
bug.cpp:45:9: note: declared here
  struct Header
         ^
bug.cpp:56:96: error: use of undeclared identifier 'code'
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, code) == 0x01)>)> poco_...
^
bug.cpp:56:111: error: type name requires a specifier or qualifier
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, code) == 0x01)>)> poco_...
^
bug.cpp:57:88: error: 'Header' does not refer to a value
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, checksum) == 0x02)>)> p...
^
bug.cpp:45:9: note: declared here
  struct Header
         ^
bug.cpp:57:96: error: use of undeclared identifier 'checksum'
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, checksum) == 0x02)>)> p...
^
bug.cpp:57:115: error: type name requires a specifier or qualifier
...poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, checksum) == 0x02)>)> poco_stati...
^
bug.cpp:58:88: error: 'Header' does not refer to a value
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, id) == 0x04)>)> poco_st...
^
bug.cpp:45:9: note: declared here
  struct Header
         ^
bug.cpp:58:96: error: use of undeclared identifier 'id'
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, id) == 0x04)>)> poco_st...
^
bug.cpp:58:109: error: type name requires a specifier or qualifier
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, id) == 0x04)>)> poco_st...
^
bug.cpp:59:88: error: 'Header' does not refer to a value
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, seq) == 0x06)>)> poco_s...
^
bug.cpp:45:9: note: declared here
  struct Header
         ^
bug.cpp:59:96: error: use of undeclared identifier 'seq'
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, seq) == 0x06)>)> poco_s...
^
bug.cpp:59:110: error: type name requires a specifier or qualifier
  typedef 
poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) 
(offsetof(Header, seq) == 0x06)>)> poco_s...
^
12 errors generated.
fandre at ubuntu-trusty-64:~/clang$

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170722/d4872378/attachment.html>
-------------- next part --------------
#include <iostream>
#include <cstddef>
#ifdef Header
#undef Header
#endif

#define POCO_JOIN(X, Y) POCO_DO_JOIN(X, Y)
#define POCO_DO_JOIN(X, Y) POCO_DO_JOIN2(X, Y)
#define POCO_DO_JOIN2(X, Y) X##Y

#define POCO_UNUSED

template <bool x>
struct POCO_STATIC_ASSERTION_FAILURE;

template <>
struct POCO_STATIC_ASSERTION_FAILURE<true>
{
	enum
	{
		value = 1
	};
};


template <int x> 
struct poco_static_assert_test
{
};

#if 0
#define poco_static_assert(B) \
	typedef char POCO_JOIN(poco_static_assert_typedef_, __LINE__) \
        [POCO_STATIC_ASSERTION_FAILURE<(bool) (B)>::value]
#else
#define poco_static_assert(B) \
	typedef poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) (B)>)> \
		POCO_JOIN(poco_static_assert_typedef_, __LINE__) POCO_UNUSED
#endif

using namespace std;
class Foo {
public:

 struct Header
 {
  char type;
  char code;
  short checksum;
  short id;
  short seq;
 };



 typedef poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) (offsetof(Header, code) == 0x01)>)> poco_static_assert_typedef_53 __attribute__((unused));
 typedef poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) (offsetof(Header, checksum) == 0x02)>)> poco_static_assert_typedef_54 __attribute__((unused));
 typedef poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) (offsetof(Header, id) == 0x04)>)> poco_static_assert_typedef_55 __attribute__((unused));
 typedef poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) (offsetof(Header, seq) == 0x06)>)> poco_static_assert_typedef_56 __attribute__((unused));

};
int main() {
	cout << "Hi!" << endl;
	return 0;
}


More information about the cfe-dev mailing list