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

            Bug ID: 88979
           Summary: [C++20] P0634R3 not working for constructor parameter
                    types
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 19Sebastian95 at gmx dot de
  Target Milestone: ---

# gcc -v
Using built-in specs.
COLLECT_GCC=/opt/bin/gcc
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/opt/ --enable-languages=c,c++
Thread model: posix
gcc version 9.0.0 20190118 (experimental) (GCC) 

# Description: 
When compiling the following code and uncommenting the first constructor of A
it'll throw the error in the comment. 
The expected behaviour would either be "error: need 'typename' before 'T::type'
because 'T' is a dependent scope" or no error at all.

# Options: 
-O2 -std=c++2a -Wall -Wextra

# Source Code:
template<typename T>
class A {
public:
    using type = T::type;
    /*A(T::type a) : mA{a} {}*/ // error: expected ')' before 'a'
    A(type a); // OK
    constexpr void a(T::type a) noexcept { // OK
        mA = a;
    }
    [[nodiscard]] constexpr T::type a() const noexcept { // OK
        return mA;
    }
private:
    T::type mA; // OK
};

template<typename T>
A<T>::A(T::type a) : mA{a} {} // OK


struct B {
    using type = int;
};

int main() {
    A<B> a{20};
    a.a(10);
    return a.a();
}

Reply via email to