* Iain Sandoe:

> diff --git a/gcc/testsuite/g++.dg/cpp26/observable-checkpoint.C 
> b/gcc/testsuite/g++.dg/cpp26/observable-checkpoint.C
> new file mode 100644
> index 00000000000..886cda7ae33
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp26/observable-checkpoint.C
> @@ -0,0 +1,24 @@
> +// P1494R5+P3641R0 - Partial program correctness.
> +// { dg-do compile { target c++11 } }
> +// { dg-additional-options "-fdump-tree-optimized -Wno-return-type -O" }
> +// { dg-final { scan-tree-dump  {\+\s42} "optimized" } }
> +// { dg-final { scan-tree-dump  {__builtin_observable_checkpoint} 
> "optimized" } }
> +
> +int x = 0;
> +
> +int
> +here_b_ub ()
> +{
> +  // missing return triggers UB (we must ignore the warning for this test). 
> +}
> +
> +int
> +main ()
> +{
> +  __builtin_printf (" start \n");
> +  x += 42;
> +  // Without this checkpoint the addition above is elided (along with the 
> rest
> +  // of main).
> +  __builtin_observable_checkpoint ();
> +  here_b_ub ();
> +}

What happens if you have this?

static int x = 0;

Does the linkage matter?

Thanks,
Florian

Reply via email to