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

            Bug ID: 129198
           Summary: ICE with counted_by and UBSAN
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: b.buschinski at googlemail dot com
  Target Milestone: ---

Compiler explorer: https://godbolt.org/z/8G858P51P

For the code (minimized by cvise, from over 5000+ lines of code + many macros):
```
struct my_string *parse_input_state_1_0_0_0;
struct my_string {
  char *buffer __attribute__((counted_by(length)));
  long length
} parse_input() {
  parse_input_state_1_0_0_0[0].buffer +
      (long)parse_input;
}

```

Compile it with ubsan (-fsanitize=undefined)

And it will result in:

```
during GIMPLE pass: sanopt
<source>: In function 'parse_input':
<source>:5:3: internal compiler error: in ubsan_encode_value, at ubsan.cc:162
    5 | } parse_input() {
      |   ^~~~~~~~~~~
0x29c02b8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x29b4efb internal_error(char const*, ...)
        ???:0
0xb2ab9e fancy_abort(char const*, int, char const*)
        ???:0
0x1345d7b ubsan_expand_bounds_ifn(gimple_stmt_iterator*)
        ???:0
/cefs/d1/d113c5cd2322ed1978ca1154_gcc-trunk-20261130/bin/../libexec/gcc/x86_64-linux-gnu/17.0.0/cc1
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/d1/d113c5cd2322ed1978ca1154_gcc-trunk-20261130/bin/../lib/gcc/x86_64-linux-gnu/17.0.0/
<source> -quiet -dumpdir /app/ -dumpbase output.c -dumpbase-ext .c
-mtune=generic -march=x86-64 -g -fdiagnostics-color=always -fno-verbose-asm
-fsanitize=undefined -o /app/output.s
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```

without UBSAN or without counted_by it works fine.
  • [Bug c/129198] New: ICE wi... b.buschinski at googlemail dot com via Gcc-bugs

Reply via email to