https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87554

--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
With first bad revision the constructor looks as follows:

$ (gdb) p print_generic_expr(stderr, decl->decl_common.initial, 0)
instance = b<k>::create ()$1 = void
(gdb) p debug_tree(decl->decl_common.initial)
 <init_expr 0x7ffff6cc0a50
    type <reference_type 0x7ffff6cbe540
        type <record_type 0x7ffff6cb5f18 k type_5 type_6 SI
            size <integer_cst 0x7ffff6b730c0 constant 32>
            unit-size <integer_cst 0x7ffff6b730d8 constant 4>
            align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6cb5f18 fields <function_decl 0x7ffff6cc8700 __ct > context
<translation_unit_decl 0x7ffff6b60168
/home/marxin/Programming/testcases/pr87554.ii>
            full-name "struct k"
            X() X(constX&) this=(X&) n_parents=0 use_template=0
interface-unknown
            pointer_to_this <pointer_type 0x7ffff6cbe9d8> reference_to_this
<reference_type 0x7ffff6cbe540> chain <type_decl 0x7ffff6c7bda8 k>>
        unsigned DI
        size <integer_cst 0x7ffff6b53e70 constant 64>
        unit-size <integer_cst 0x7ffff6b53e88 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff6cbe540>
    side-effects
    arg:0 <var_decl 0x7ffff6cbd2d0 instance type <reference_type
0x7ffff6cbe540>
        readonly used public static tree_1 tree_3 unsigned external nonlocal
read decl_3 decl_5 DI /home/marxin/Programming/testcases/pr87554.ii:11:25 size
<integer_cst 0x7ffff6b53e70 64> unit-size <integer_cst 0x7ffff6b53e88 8>
        align:64 warn_if_not_align:0 context <record_type 0x7ffff6cbe348 b>
initial <init_expr 0x7ffff6cc0a50>
        template-info 0x7ffff6ca6f20
        chain <type_decl 0x7ffff6cbf1c8 b type <record_type 0x7ffff6cbe3f0 b>
            external nonlocal suppress-debug decl_4 VOID
/home/marxin/Programming/testcases/pr87554.ii:1:30
            align:8 warn_if_not_align:0 context <record_type 0x7ffff6cbe348 b>
result <record_type 0x7ffff6cbe348 b>
           >>
    arg:1 <call_expr 0x7ffff6cca090 type <reference_type 0x7ffff6cbe540>
        side-effects
        fn <addr_expr 0x7ffff6cc2e40 type <pointer_type 0x7ffff6cc47e0>
            constant arg:0 <function_decl 0x7ffff6cc1000 create>>
        /home/marxin/Programming/testcases/pr87554.ii:11:50 start:
/home/marxin/Programming/testcases/pr87554.ii:11:44 finish:
/home/marxin/Programming/testcases/pr87554.ii:11:51>>

before that C++ FE reported following error:

$ ./xgcc -B. ~/Programming/testcases/pr87554.ii -c -O2
/home/marxin/Programming/testcases/pr87554.ii: In instantiation of ‘k&
b<k>::instance’:
/home/marxin/Programming/testcases/pr87554.ii:3:26:   required from ‘static a&
b<a>::create() [with a = k]’
/home/marxin/Programming/testcases/pr87554.ii:8:24:   required from ‘static a
b<a>::d() [with a = k]’
/home/marxin/Programming/testcases/pr87554.ii:26:55:   required from ‘void p(m,
a) [with m = e*; a = int]’
/home/marxin/Programming/testcases/pr87554.ii:16:39:   required from ‘void
f::h(a) [with a = int]’
/home/marxin/Programming/testcases/pr87554.ii:15:31:   required from here
/home/marxin/Programming/testcases/pr87554.ii:11:50: error: call to
non-‘constexpr’ function ‘static a& b<a>::create() [with a = k]’
 template < class a > a &b< a >::instance = create();
                                            ~~~~~~^~

Jason can you please take a look?

Reply via email to