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

            Bug ID: 78022
           Summary: Strange C++ compilation error
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fiesh at zefix dot tv
  Target Milestone: ---

The following piece of code does not compile.  Since clang 3.8.1 compiles it,
and furthermore changes that would appear inconsequential make it compile, I
suspect it might be an issue of GCC:

------------------
#include <array>

template<typename T>
struct A
{
        template<typename... Args>
                constexpr A(Args&&... args) :
                        entries_{std::forward<Args>(args)...} {}
        std::array<T, 1> entries_;
};

struct B : public A<int>
{
        using A<int>::A;
};

// Uncommenting the following line makes this file compile.
//constexpr B p{0};
// Commenting the following line makes this file compile.
template<typename>
struct X
{
        X()
        {
                // The following line is fine.
                const B b0{0};
                // The following line produces an error.
                constexpr B b1{0};
        }
};
------------------

The output is as follows:
% g++ -std=c++11 -c test.cpp
test.cpp: In constructor ‘X<T>::X()’:
test.cpp:31:20: error: ‘constexpr B::B(Args&& ...) [with Args = {int}]’ used
before its definition
    constexpr B b1{0};

Reply via email to