This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/86959] New: Use of a variadic alias template unexpectedly breaks compilation


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86959

            Bug ID: 86959
           Summary: Use of a variadic alias template unexpectedly breaks
                    compilation
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: v.reshetnikov at gmail dot com
  Target Milestone: ---

/*********************** BEGIN SOURCE ***********************/
template<class>
struct Outer {
    template<class...>
    struct Inner;

    template<class... T>
    using Alias = Inner<T...>;
};

template<>
template<class... T>
struct Outer<void>::Inner { 
    static constexpr auto value = sizeof...(T);
};

static_assert(Outer<void>::Inner<void>::value == 1); // OK
static_assert(Outer<void>::Alias<void>::value == 1); // error

/************************ END SOURCE ************************/

The first static_assert compiles OK, but the second results in unexpected
errors:

/*********************** BEGIN OUTPUT ***********************/
<source>: In instantiation of 'struct Outer<void>::Inner<void>':
<source>:17:39:   required from here
<source>:12:27: error: template argument 1 is invalid
12 | struct Outer<void>::Inner {
   |                           ^
<source>:12:27: error: template argument 1 is invalid
<source>:13:27: error: template argument 1 is invalid
13 |     static constexpr auto value = sizeof...(T);
   |                           ^~~~~
<source>:13:27: error: template argument 1 is invalid
<source>:17:41: error: 'value' is not a member of 'Outer<void>::Alias<void>'
{aka 'Outer<void>::Inner<void>'}
17 | static_assert(Outer<void>::Alias<void>::value == 1); // error
   |                                         ^~~~~
Compiler returned: 1

/************************ END OUTPUT ************************/

The issue was discovered with build 9.0.0 20180813 (experimental), but appears
to exist in earlier versions as well.

For comparison, Clang compiles this code successfully.

Might be related to Bug 86956 and Bug 86958.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]