[C++ PATCH] RFC: implement P0386R2 - C++17 inline variables

Jakub Jelinek jakub@redhat.com
Thu Oct 20 11:02:00 GMT 2016


On Thu, Oct 20, 2016 at 12:50:56PM +0200, Eric Botcazou wrote:
> > testsuite/
> > 	* g++.dg/cpp1z/inline-var1.C: New test.
> > 	* g++.dg/cpp1z/inline-var1a.C: New test.
> > 	* g++.dg/cpp1z/inline-var1.h: New file.
> 
> This one fails on SPARC/Solaris:
> 
> 0xfefcaa58 in _lwp_kill () from /lib/libc.so.1
> (gdb) bt
> #0  0xfefcaa58 in _lwp_kill () from /lib/libc.so.1
> #1  0xfef65a64 in raise () from /lib/libc.so.1
> #2  0xfef41954 in abort () from /lib/libc.so.1
> #3  0x00011770 in bar (x=16) at inline-var1.C:34
> #4  0x00012984 in __static_initialization_and_destruction_0 (__initialize_p=1, 
>     __priority=65535) at inline-var1a.C:6
> #5  0x00012b18 in _GLOBAL__sub_I_alt1 () at inline-var1a.C:44
> #6  0x00012b54 in __do_global_ctors_aux ()
> #7  0x00012b8c in _init ()
> #8  0x00011458 in _start ()
> 
> (gdb) frame 3
> #3  0x00011770 in bar (x=16) at inline-var1.C:34
> 34              __builtin_abort ();
> 
> (gdb) frame 4
> #4  0x00012984 in __static_initialization_and_destruction_0 (__initialize_p=1, 
>     __priority=65535) at inline-var1a.C:6
> 6       static inline int var19 = bar (16);
> 
> (gdb) p w
> $2 = 0
> 
> The testcase is rather cryptic, in particular the logic in 'bar', so it's hard 
> to figure out what doesn't work as expected, but does it require support for 
> constructor priorities for example?  Or does it assume an order of invocation 
> for the constructors of inline-var1.C vs those of inline-var1a.C?

The test wants to ensure:
1) the foo calls in the ctors are invoked in increasing order (this is used
   for inline vars defined in both CUs)
2) ensure that the first bar call in the ctors is invoked after foo (5)
3) that bar used in ctors (it is used for inline vars defined in one or the
   other CU, but not both) is invoked either in the order
   bar (0); bar (1); /* optionally some foo calls here */ bar (16); bar (17);
   or in the order
   bar (16); bar (17); /* optionally some foo calls here */ bar (0); bar (1);

So, in what order is it run on Solaris and why does it fail?

	Jakub



More information about the Gcc-patches mailing list