[Bug c++/58752] New: [C++11] Bogus error: ambiguous class template instantiation

ppluzhnikov at google dot com gcc-bugzilla@gcc.gnu.org
Wed Oct 16 17:38:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58752

            Bug ID: 58752
           Summary: [C++11] Bogus error: ambiguous class template
                    instantiation
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppluzhnikov at google dot com

Test:

#include <type_traits>

template <class T, class U = void> struct Foo;

#if BUG
template <class T>
struct Foo<T, typename std::enable_if<sizeof(T) != 0>::type> {};
#else
template <class T>
struct Foo<T, std::true_type> {};
#endif

template <class T> struct Foo<const T> {};

int main()
{
  Foo<const char>();
}


Using trunk g++ (GCC) 4.9.0 20131016 (experimental)

g++ -std=c++11 -c t.cc && echo ok
ok

g++ -std=c++11 -c t.cc -DBUG
t.cc: In function 'int main()':
t.cc:17:19: error: ambiguous class template instantiation for 'struct Foo<const
char>'
  Foo<const char>();
                  ^
t.cc:7:8: error: candidates are: struct Foo<T, typename std::enable_if<(sizeof
(T) != 0)>::type>
 struct Foo<T, typename std::enable_if<sizeof(T) != 0>::type> {};
       ^
t.cc:13:27: error:                 struct Foo<const T>
 template <class T> struct Foo<const T> {};
                          ^
t.cc:17:19: error: invalid use of incomplete type 'struct Foo<const char>'
  Foo<const char>();   // Error
                  ^
t.cc:3:43: error: declaration of 'struct Foo<const char>'
 template <class T, class U = void> struct Foo;
                                          ^


Google ref: b/11253052



More information about the Gcc-bugs mailing list