[Bug middle-end/87757] weird underlining and colors in sprintf warnings for unterminated arrays

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Oct 25 23:51:00 GMT 2018


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |dmalcolm at gcc dot gnu.org
           Severity|normal                      |minor

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
In the first case the argument seen by the sprintf pass is:

 <addr_expr 0x7fffefc0a0a0
    type <pointer_type 0x7fffefbe8e70
        type <array_type 0x7fffefbe8690 type <integer_type 0x7fffefae51f8 char>
            QI
            size <integer_cst 0x7fffefac0d68 constant 8>
            unit-size <integer_cst 0x7fffefac0d80 constant 1>
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffefbe8690 domain <integer_type 0x7fffefae4d20>
            pointer_to_this <pointer_type 0x7fffefbe8e70>>
        unsigned DI
        size <integer_cst 0x7fffefac0c78 constant 64>
        unit-size <integer_cst 0x7fffefac0c90 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffefbe8e70>
    readonly constant
    arg:0 <var_decl 0x7ffff7ff5ab0 a type <array_type 0x7fffefbe8690>
        readonly addressable used public static read QI /build/tmp/t.c:1:12
size <integer_cst 0x7fffefac0d68 8> unit-size <integer_cst 0x7fffefac0d80 1>
        align:8 warn_if_not_align:0 context <translation_unit_decl
0x7fffefacdc30 /build/tmp/t.c> initial <string_cst 0x7fffefbf1cd8>
        chain <var_decl 0x7ffff7ff5b40 d type <pointer_type 0x7fffefae4e70>
            used public static unsigned common read DI /build/tmp/t.c:3:7 size
<integer_cst 0x7fffefac0c78 64> unit-size <integer_cst 0x7fffefac0c90 8>
            align:64 warn_if_not_align:0 context <translation_unit_decl
0x7fffefacdc30 /build/tmp/t.c> chain <var_decl 0x7ffff7ff5bd0 e>>>
    /build/tmp/t.c:7:31 start: /build/tmp/t.c:7:31 finish: /build/tmp/t.c:7:31>


while in the second case it is:

 <addr_expr 0x7fffefc0a160
    type <pointer_type 0x7fffefae52a0
        type <integer_type 0x7fffefae51f8 char readonly string-flag QI
            size <integer_cst 0x7fffefac0d68 constant 8>
            unit-size <integer_cst 0x7fffefac0d80 constant 1>
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffefae51f8 precision:8 min <integer_cst 0x7fffefac0db0 -128> max
<integer_cst 0x7fffefac0de0 127>
            pointer_to_this <pointer_type 0x7fffefae52a0>>
        unsigned DI
        size <integer_cst 0x7fffefac0c78 constant 64>
        unit-size <integer_cst 0x7fffefac0c90 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffefae52a0>
    readonly constant
    arg:0 <array_ref 0x7fffefacc0a8 type <integer_type 0x7fffefae51f8 char>
        readonly
        arg:0 <var_decl 0x7ffff7ff5ab0 a type <array_type 0x7fffefbe8690>
            readonly addressable used public static read QI /build/tmp/t.c:1:12
size <integer_cst 0x7fffefac0d68 8> unit-size <integer_cst 0x7fffefac0d80 1>
            align:8 warn_if_not_align:0 context <translation_unit_decl
0x7fffefacdc30 /build/tmp/t.c> initial <string_cst 0x7fffefbf1cd8> chain
<var_decl 0x7ffff7ff5b40 d>>
        arg:1 <integer_cst 0x7fffefadf018 constant 0>
        /build/tmp/t.c:8:33 start: /build/tmp/t.c:8:32 finish:
/build/tmp/t.c:8:35>
    /build/tmp/t.c:8:3 start: /build/tmp/t.c:8:3 finish: /build/tmp/t.c:8:36>

The (presumably) relevant difference in the locations of the two is:

    /build/tmp/t.c:7:31 start: /build/tmp/t.c:7:31 finish: /build/tmp/t.c:7:31

vs

    /build/tmp/t.c:8:3 start: /build/tmp/t.c:8:3 finish: /build/tmp/t.c:8:36

Not sure where that comes from, but the ADDR_EXPR operand does have the right
location.


More information about the Gcc-bugs mailing list