view gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-tmpl.C @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 2b5abeee2509
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 ();