[cfe-dev] Clang 3.2 error or incorrect code ?
Matthieu Monrocq
matthieu.monrocq at gmail.com
Fri Jan 18 08:35:09 PST 2013
The snippet below is successfully compiled by gcc 4.7.2:
template <typename T, unsigned N>struct Helper {};
template <typename T, unsigned N >Helper< T, N > GetHelper() { return
Helper< T, N > (); }
template < typename T, unsigned N >struct X {
X( Helper< T, N > h = GetHelper<T, N>() ) {}};
With clang 3.2 though it spews a lot of errors:
Compilation finished with errors:
source.cpp:9:40: error: unknown type name 'N'
X( Helper< T, N > h = GetHelper<T, N>() ) {}
^
source.cpp:9:41: error: expected ')'
X( Helper< T, N > h = GetHelper<T, N>() ) {}
^
source.cpp:9:6: note: to match this '('
X( Helper< T, N > h = GetHelper<T, N>() ) {}
^
source.cpp:9:38: error: expected '>'
X( Helper< T, N > h = GetHelper<T, N>() ) {}
^
3 errors generated.
for the exact position of the carets, you can see:
http://liveworkspace.org/code/3EALA5$27
- the first caret is positionned under the N of GetHelper<T, N>()
- the second caret is positionned under the > of GetHelper<T, N>()
- the fourth caret is positionned under the comma of GetHelper<T, N>()
I suspect a clang bug, given that gcc manages to compile the code.
Note: related SO question => http://stackoverflow.com/q/14401308/147192
-- Matthieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130118/27f666b0/attachment.html>
More information about the cfe-dev
mailing list