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

            Bug ID: 99198
           Summary: when combinating nested function and
                    __builtin_call_with_static_chain, optimization
                    triggers an internal compiler error (verify_gimple)
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhan3299 at purdue dot edu
  Target Milestone: ---

Following code is reduced by c-reduce and meaningless, but seems valid as gcc
-O0 accept it. 

Under O0, the program can be successfully compiled
(https://godbolt.org/z/zvGxTP); but under O1, it triggers an internal compiler
error (https://godbolt.org/z/xbvrs6). Besides, any version prior version 11.0
has no such problem.

$ cat test.c
int main() {
    void f() {}
    __builtin_call_with_static_chain(f(), &f);

    return 0;
}

$ gcc --version
gcc (Compiler-Explorer-Build) 11.0.0 20210221 (experimental)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc -O0 test.c # Execution build compiler returned: 0

$ gcc -O1 test.c
<source>: In function 'main':
<source>:1:5: error: static chain with function that doesn't use one
    1 | int main() {
      |     ^~~~
f (); [static-chain: f]
during GIMPLE pass: *warn_unused_result
<source>:1:5: internal compiler error: 'verify_gimple' failed
0x1a31d99 internal_error(char const*, ...)
        ???:0
0xdc218d verify_gimple_in_seq(gimple*)
        ???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Reply via email to