[cfe-dev] Clang 3.2 error or incorrect code ?

Richard Smith richard at metafoo.co.uk
Fri Jan 18 09:45:44 PST 2013


See PR13657
On 18 Jan 2013 08:37, "Matthieu Monrocq" <matthieu.monrocq at gmail.com> wrote:

> 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
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130118/7baa4282/attachment.html>


More information about the cfe-dev mailing list