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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Simpler testcase, the class doesn't need to be a template, but check does:
struct S
{
  constexpr S () { }
  ~S () { }
};

template <typename T>
constexpr bool check ()
{
  T t;
  return true;
}

constexpr bool a = check<S> ();

constexpr bool check2 ()
{
  S s;
  return true;
}

constexpr bool b = check2 ();

because check2 is diagnosed properly:
pr102262.C: In function ‘constexpr bool check2()’:
pr102262.C:18:5: error: variable ‘s’ of non-literal type ‘S’ in ‘constexpr’
function
   18 |   S s;
      |     ^
pr102262.C:1:8: note: ‘S’ is not literal because:
    1 | struct S
      |        ^
pr102262.C:1:8: note:   ‘S’ does not have ‘constexpr’ destructor

Reply via email to