Bug 117761 - Incorrect name lookup within decltype used as part of an id-expression for a class member access
Summary: Incorrect name lookup within decltype used as part of an id-expression for a ...
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 15.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on: P1787R6
Blocks: c++-lookup, c++-name-lookup decltype
  Show dependency treegraph
 
Reported: 2024-11-24 06:59 UTC by Halalaluyafail3
Modified: 2024-11-24 12:31 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.7.1
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Halalaluyafail3 2024-11-24 06:59:50 UTC
GCC incorrectly handles name lookup within decltypes in locations such as the following:

struct{int x;}x;
int main(){
    x.decltype(x)::x=42;
}

Here, the x in decltype(x) should refer to the structure x and not the member x. GCC however decides to do member lookup same as it would outside of decltype and finds the member x, which then results in GCC emitting an error because of trying to access a member named x in the type int. Clang and MSVC both accept this code.
Comment 2 Andrew Pinski 2024-11-24 07:05:28 UTC
(In reply to Andrew Pinski from comment #1)
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1787r6.html

That is gcc does not currently implements this paper.