[cfe-users] Invalid use of non-static member of struct nested inside of class template
Bobby Moretti via cfe-users
cfe-users at lists.llvm.org
Mon Mar 7 15:44:23 PST 2016
In clang 3.6.2, the following code results in a compilation error:
template <typename T=void>
$ clang++ -std=c++11 nonstatic.cpp -o nonstatic
nonstatic.cpp:12:28: error: invalid use of non-static data member 'array'
nonstatic.cpp:20:14: note: in instantiation of member function
'bar<void>::baz' requested here
1 error generated.
If `bar` is no longer a template (just remove the first line and the
angle brackets in `bar<> b;`), then the code compiles cleanly. I get
the same error in both clang 3.6.2 final and 3.8.0-svn257294-1~exp1.
The same code also compiles cleanly in gcc version 5.2.1.
It seems strange to me that this would result in an error, but I have
not yet tried to see what the standard says. Can anyone with confirm
whether this code should be valid or not?
$ clang++ --version
Ubuntu clang version 3.6.2-1 (tags/RELEASE_362/final) (based on LLVM 3.6.2)
Thread model: posix
bobmoretti at gmail.com
More information about the cfe-users