[cfe-dev] Clang template parse problem?
Douglas Gregor
dgregor at apple.com
Wed Jun 6 14:19:35 PDT 2012
On Jun 6, 2012, at 7:45 AM, Thiago Adams <thiago.adams at gmail.com> wrote:
> I am having problems to compile this program using clang
> and it seems a parser bug.
>
> clang version 3.2 (trunk)
> Target: i686-pc-win32
> Thread model: posix
>
> (Thanks Mello for providing a updated build for windows.)
>
>
> Simplified code:
>
> ----------
> #include <type_traits>
>
> struct Property {};
> struct Property2 : public Property {};
>
> template<class T>
> struct is_property : public std::is_base_of<Property, T> {};
>
> template <class TA, class TB>
> auto operator > (const TA& a, const TB& b)
> -> typename std::enable_if < is_property<TA>::value ||
> is_property<TB>::value,
> decltype(eval(a) > eval(b)) >::type
> {
> return true;
> }
>
> int main()
> {
> Property2 a;
> Property2 b;
> if (a > b)
> return 1;
> return 0;
> }
>
> ----------
>
> error: expected ')'
> decltype(eval(a) > eval(b)) >::type
>
> ^ points to ">"
>
> -----------
>
>
> Is it a bug?
Yes, it's a Clang bug. Thanks!
> I am new to clang. Where do I report this problem?
Bug reports for Clang and LLVM should go here:
http://llvm.org/bugs/
But, don't bother for this bug, because I went ahead and fixed this already in Clang r158111.
> The workaround is to change:
>
> decltype(eval(a) > eval(b))
Wrapping eval(a) > eval(b) in another set of parentheses should work, too.
- Doug
More information about the cfe-dev
mailing list