Hi,

In clang 3.6.2, the following code results in a compilation error:

template <typename T=void>
class bar
{
public:
    struct foo
    {
        int array[10];
    };

    int baz()
    {
        return sizeof(foo::array);
    }
};

int main(void)
{
    bar<> b;
    return b.baz();
}

$ clang++ -std=c++11 nonstatic.cpp -o nonstatic
nonstatic.cpp:12:28: error: invalid use of non-static data member 'array'
        return sizeof(foo::array);
                      ~~~~~^~~~~
nonstatic.cpp:20:14: note: in instantiation of member function
'bar<void>::baz' requested here
    return b.baz();
             ^
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?

Version details:

$ clang++ --version
Ubuntu clang version 3.6.2-1 (tags/RELEASE_362/final) (based on LLVM 3.6.2)
Target: x86_64-pc-linux-gnu
Thread model: posix


Thanks,
Bobby

-- 
Bobby Moretti
bobmore...@gmail.com
_______________________________________________
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Reply via email to