On Mon, 20 Aug 2018, Szabolcs Nagy wrote:

> On 02/08/18 09:30, Richard Biener wrote:
> > --- gcc/testsuite/g++.dg/torture/pr86763.C  (nonexistent)
> > +++ gcc/testsuite/g++.dg/torture/pr86763.C  (working copy)
> > @@ -0,0 +1,36 @@
> > +// { dg-do run }
> > +// { dg-additional-options "-fschedule-insns2 -fstrict-aliasing" }
> > +
> > +#include <cstdint>
> > +#include <cassert>
> > +#include <time.h>
> > +struct ID {
> > +  uint64_t value;
> > +};
> > +uint64_t value(ID id) { return id.value; }
> > +uint64_t gen { 1000 };
> > +struct Msg {
> > +  uint64_t time;
> > +  ID id;
> > +};
> > +struct V {
> > +  V() { }
> > +  V(Msg const & msg) : msg(msg) { }
> > +  Msg & get() { return msg; }
> > +  Msg msg;
> > +  char pad[237 - sizeof(Msg)];
> > +};
> > +struct T : V { using V::V; };
> > +Msg init_msg() {
> > +  Msg msg;
> > +  timespec t;
> > +  clock_gettime(CLOCK_REALTIME, &t);
> 
> this fails on targets without clock_gettime (baremetal)
> or targets that need -lrt at link time.
> 
> can we use something else here?
> e.g. time(&t) works on baremetal and does not depend on -lrt.

You'd have to check that the original bug still reproduces.  Since
it depends on scheduling chances may be that it is fragile :/

I suppose we could restrict the testcase to { *-*-linux }?

Richard.

> > +  msg.time = t.tv_sec + t.tv_nsec;
> > +  msg.id.value = ++gen;
> > +  return msg;
> > +}
> > +int main() {
> > +  T t;
> > +  t = init_msg();
> > +  assert(value(t.get().id) == 1001);
> > +}
> > 
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)

Reply via email to