view gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-tmpl.C @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents
children
line wrap: on
line source

// PR c++/94951
// { dg-do compile }
// { dg-options "-O2 -Wall" }

struct A { int a; };
template <int N>
struct B : public A
{
  static B<N> foo () { B<N> t; t.a = 4; return t; }	// { dg-bogus "dereferencing type-punned pointer will break strict-aliasing rules" }
};

B<0> b = B<0>::foo ();