Bug 114491 - incorrect identifier namespacing with variadic templates
Summary: incorrect identifier namespacing with variadic templates
Status: RESOLVED DUPLICATE of bug 90189
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: c++-lookup, c++-name-lookup
  Show dependency treegraph
 
Reported: 2024-03-27 00:20 UTC by Christoph Schied
Modified: 2024-03-27 00:26 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-03-27 00:00:00


Attachments
same source code as posted in the description (113 bytes, text/plain)
2024-03-27 00:20 UTC, Christoph Schied
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Schied 2024-03-27 00:20:17 UTC
Created attachment 57818 [details]
same source code as posted in the description

The following code fails to compile with g++, however it works with clang. I tried various versions of gcc in godbolt (https://godbolt.org/z/xqfoc4Yce) using std=c++17 and std=c++20 and the code fails to compile on all versions. It appears that the dependent type T gets confused with the template argument of the function.

template<typename A, typename... X>
void works()
{
    typename A::T var;
}

template<typename A, typename... T>
void broken()
{
    typename A::T var; /* A::T and T seem to clash */
}


results in:
<source>: In function 'void broken()':
<source>:10:19: error: parameter packs not expanded with '...':
   10 |     typename A::T var; /* A::T and T seem to clash */
      |                   ^~~
<source>:10:19: note:         'T'
Comment 1 Drea Pinski 2024-03-27 00:25:22 UTC
Confirmed.

Interesting:
```
template<typename A, auto... T>
void works_also()
{
    typename A::T var; /* A::T and T seem to clash */
}
```

Works also.
Comment 2 Drea Pinski 2024-03-27 00:26:10 UTC
Oh but it is a duplicate.

*** This bug has been marked as a duplicate of bug 90189 ***