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

--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Patrick Palka from comment #5)
> The ICE seems to be revealing a latent issue:  In the following example
> (which GCC accepts), according to the static_assert labelled (1), the type
> of t is const int*, but according to the static_assert labelled (2), the
> type of t is int *const.
> 
> 
> 
> template <typename T>
> void foo(const T t)
> {
>   static_assert(__is_same(decltype(t), const int*));  // (1)
> }
> 
> static_assert(__is_same(decltype(foo<int[]>), void(int *)));  // (2)
> 
> int
> main()
> {
>   foo<int[]>(nullptr);
> }

So the question becomes, what should the type of t be here?  According to
https://eel.is/c++draft/temp#deduct-3:

"A top-level qualifier in a function parameter declaration does not affect the
function type but still affects the type of the function parameter variable
within the function."

The above suggests that the type of foo<int[]> should be the same regardless of
where the parameter t is const-qualified.  Going by this then, it appears that
the static_assert (2) is right and (1) is wrong.  Can anyone confirm?

(On the other hand, Clang thinks (1) is right and (2) is wrong.)

Reply via email to