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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |katzdm at gmail dot com

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Changing that to https://godbolt.org/z/8zobsdoWe
#include <meta>

extern int a[];

consteval auto
f ()
{
  extern int a[3];
  auto ret = ^^a;
  static_assert(std::is_same_v<decltype(a),decltype([:^^a:])>);
  return ret;
}
static_assert(std::is_same_v<decltype(a),decltype([:f():])>);
static_assert(^^a == f());
so that the use of ret in static_assert error is gone, clang++ branch rejects
that with
<source>:10:17: error: static assertion failed due to requirement
'std::is_same_v<int[3], int (&)[]>'
   10 |   static_assert(std::is_same_v<decltype(a),decltype([:^^a:])>);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:13:15: error: static assertion failed due to requirement
'std::is_same_v<int[], int (&)[]>'
   13 | static_assert(std::is_same_v<decltype(a),decltype([:f():])>);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
so ^^a in there is clearly for DECL_LOCAL_DECL_P vars/function decls the
DECL_LOCAL_DECL_ALIAS rather than the local alias.  Plus decltype in those is a
reference to array rather than array.
While with gcc
<source>:13:20: error: static assertion failed
   13 | static_assert(std::is_same_v<decltype(a),decltype([:f():])>);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • 'int []' is not the same as 'int [3]'
<source>:14:19: error: static assertion failed
   14 | static_assert(^^a == f());
      |                 ~~^~~~~~
i.e. we use the local alias.
It is unclear to me what is right and whether something in the standard needs
to be clarified for this, e.g. the local alias can have different defaulted
arguments, etc.

Reply via email to