Bug 110101 - inconsistent behavior for array-to-pointer decay in constant evaluation in template argument
Summary: inconsistent behavior for array-to-pointer decay in constant evaluation in te...
Status: UNCONFIRMED
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: ABI
Depends on:
Blocks: 24666
  Show dependency treegraph
 
Reported: 2023-06-02 23:55 UTC by Richard Smith
Modified: 2023-06-05 06:40 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Smith 2023-06-02 23:55:51 UTC
Testcase:

template<void *> struct X {};
int arr[32];
constexpr void *id(void *p) { return p; }
void f(X<id(arr)>) {} // #1
void f(X<id(&arr)>) {} // #2
void f(X<id(&arr[0])>) {} // #3

Here, the three template arguments all represent the same address, but #1 and #3 point to the first array element whereas #2 points to the array itself.

But GCC instead says that #1 and #2 are redefinitions, and that #1/#2 and #3 do not conflict -- and mangles #1 and #2 the same, but gives a different mangling to #3.

It looks like the array-to-pointer conversion is not being properly handled here.