[PATCH][C++] Fix PR86763, wrong-code with TYPE_TYPELESS_STORAGE
Szabolcs Nagy
szabolcs.nagy@arm.com
Mon Aug 20 09:30:00 GMT 2018
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.
> + 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);
> +}
>
More information about the Gcc-patches
mailing list