Bug 69348 - alias declarations can not be used inside qualifiers of declarators
Summary: alias declarations can not be used inside qualifiers of declarators
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 5.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
: 85127 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-01-18 16:45 UTC by Ivan Sorokin
Modified: 2023-06-09 12:37 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-11-07 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Sorokin 2016-01-18 16:45:48 UTC
GCC shows error on this code. The code works correctly on clang and MSVC.

template <class T>
struct X {
    int foo();
};

template <class T>
using foo2 = X<T>;

template <class T>
int foo2<T>::foo()
{
}

error: invalid use of incomplete type 'struct X<T>'
Comment 1 Marek Polacek 2018-11-07 20:06:22 UTC
Confirmed.
Comment 2 David Friberg 2020-12-03 11:30:18 UTC
Another similar but more common (/less contrived) example, rejects-valid e.g. for GCC 10.1.0 for all C++ version (-std=c++X with X in {98, 11, 17, 2a/20}).

// https://wandbox.org/permlink/aQpRzgcvAHOihKz5
template<typename T>
struct S {
    using type = int;
    type f() const;
};

template<typename T>
using type_t = typename S<T>::type;

template <typename T>
type_t<T> S<T>::f() const { }
// error: no declaration matches 'type_t<T> S<T>::f() const'

int main() {}

---

Brought up in https://stackoverflow.com/questions/65110143/using-typealias-in-place-of-typedef-defined-in-class-in-definition
Comment 3 Andrew Pinski 2021-08-05 06:21:57 UTC
*** Bug 85127 has been marked as a duplicate of this bug. ***
Comment 4 Andrew Pinski 2021-08-05 06:22:43 UTC
(In reply to David Friberg from comment #2)
> Another similar but more common (/less contrived) example, rejects-valid
> e.g. for GCC 10.1.0 for all C++ version (-std=c++X with X in {98, 11, 17,
> 2a/20}).

This is a different issue and should be filed seperately.
Comment 5 David Friberg 2021-08-05 10:06:22 UTC
(In reply to Andrew Pinski from comment #4)
> (In reply to David Friberg from comment #2)
> > Another similar but more common (/less contrived) example, rejects-valid
> > e.g. for GCC 10.1.0 for all C++ version (-std=c++X with X in {98, 11, 17,
> > 2a/20}).
> 
> This is a different issue and should be filed seperately.

Thanks for the prompt Andrew. I filed Bug 101789.