This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/64035] [C++11] ICE in reshape_init_r when using initializer list aggregate initialization for default function parameters


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

Mikhail Maltsev <miyuki at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |miyuki at gcc dot gnu.org

--- Comment #6 from Mikhail Maltsev <miyuki at gcc dot gnu.org> ---
(In reply to Jonas Platte from comment #5)
> With decent experience in C++, but no experience working on GCC (or any
> other compiler), could I help fixing this?

Certainly. Some relevant wiki pages:
https://gcc.gnu.org/wiki/GettingStarted - about contributing to GCC (in
general)
https://gcc.gnu.org/wiki/DebuggingGCC - notes on debugging

Steps which seem reasonable (for me) to start debugging this particular case:
1. build the compiler with debugging information (-ggdb3) and low optimization
level (-Og)
2. run the compiler proper from build/gcc directory under debugger (suppose
that "build" is the top-level build directory and "test.cc" is your testcase):
gdb --args ./cc1plus test.cc
(note: gdb should load .gdbinit which is created in gcc directory during build;
it contains several useful macros)
3. I hit the breakpoint in fancy_abort (it is set by .gdbinit) and go one frame
up:
#1  0x0000000000605a28 in reshape_init_r (type=<array_type 0x7ffff6800348>,
d=d@entry=0x7fffffffd870, first_initializer_p=first_initializer_p@entry=false,
complain=complain@entry=2) at /home/miyuki/gcc/src/gcc/cp/decl.c:5734
5734                  gcc_assert (BRACE_ENCLOSED_INITIALIZER_P (init));

This asserion fails. I can look at the contents of "init" like this:
(gdb) p init
$1 = <constructor 0x7ffff680adf8>
(gdb) p debug_tree(init)
 <constructor 0x7ffff680adf8
    type <array_type 0x7ffff6800348
        type <integer_type 0x7ffff669f7e0 int public SI
            size <integer_cst 0x7ffff66bd0a8 constant 32>
            unit size <integer_cst 0x7ffff66bd0c0 constant 4>
            align 32 symtab 0 alias set -1 canonical type 0x7ffff669f7e0
precision 32 min <integer_cst 0x7ffff66bd060 -2147483648> max <integer_cst
0x7ffff66bd078 2147483647>
            pointer_to_this <pointer_type 0x7ffff66c1930>>
        DI
        size <integer_cst 0x7ffff669be58 constant 64>
        unit size <integer_cst 0x7ffff669be70 constant 8>
        align 32 symtab 0 alias set -1 canonical type 0x7ffff6800348
        domain <integer_type 0x7ffff68002a0 type <integer_type 0x7ffff669f1f8
sizetype>
            type_6 DI size <integer_cst 0x7ffff669be58 64> unit size
<integer_cst 0x7ffff669be70 8>
            align 64 symtab 0 alias set -1 canonical type 0x7ffff68002a0
precision 64 min <integer_cst 0x7ffff669be88 0> max <integer_cst 0x7ffff669bf60
1>>>
    constant static lngt 0>

So, init is some AST node. If I go 4 frames up, I can see an AST for the entire
initializer:

#5  0x00000000005c0305 in implicit_conversion (to=to@entry=<record_type
0x7ffff6800150 testStruct>, from=<lang_type 0x7ffff67f6a80 init list>,
expr=expr@entry=<constructor 0x7ffff680ade0>, c_cast_p=c_cast_p@entry=false, 
    flags=flags@entry=5, complain=2, complain@entry=3) at
/home/miyuki/gcc/src/gcc/cp/call.c:1763
1763          expr = reshape_init (to, expr, complain);

 <constructor 0x7ffff680ade0
    type <lang_type 0x7ffff67f6a80 init list VOID
        align 1 symtab 0 alias set -1 canonical type 0x7ffff67f6a80>
    lngt 1
    val <constructor 0x7ffff680adf8
        type <array_type 0x7ffff6800348 type <integer_type 0x7ffff669f7e0 int>
            DI
            size <integer_cst 0x7ffff669be58 constant 64>
            unit size <integer_cst 0x7ffff669be70 constant 8>
            align 32 symtab 0 alias set -1 canonical type 0x7ffff6800348 domain
<integer_type 0x7ffff68002a0>>
        constant static lngt 0>>

You need to figure out what went wrong here and why do we get unexpected AST
(perhaps by comparing it with AST that is built in "func({{}});" case).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]