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

            Bug ID: 106197
           Summary: Ignoring error line then falls into infinite recursion
                    in constexpr function
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asd1366464124 at gmail dot com
  Target Milestone: ---

Created attachment 53258
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53258&action=edit
wrong code that cause infinite recursion.

command line:g++11 -v -save-temps -Wall -Wextra -std=c++20 -fconstexpr-depth=10
a.cpp
output:
a.cpp: In function ‘consteval int fib(int)’:
a.cpp:5:5: error: ‘i’ was not declared in this scope
    5 |     i if constexpr (n == 0 || n == 1) return 1;
      |     ^
a.cpp: In function ‘int main()’:
a.cpp:11:27:   in ‘constexpr’ expansion of ‘fib(1)’
a.cpp:6:15:   in ‘constexpr’ expansion of ‘fib((n - 1))’
a.cpp:6:15:   in ‘constexpr’ expansion of ‘fib((n - 1))’
a.cpp:6:15:   in ‘constexpr’ expansion of ‘fib((n - 1))’
a.cpp:6:15:   in ‘constexpr’ expansion of ‘fib((n - 1))’
a.cpp:6:15:   in ‘constexpr’ expansion of ‘fib((n - 1))’
a.cpp:6:15:   in ‘constexpr’ expansion of ‘fib((n - 1))’
a.cpp:6:15:   in ‘constexpr’ expansion of ‘fib((n - 1))’
a.cpp:6:15:   in ‘constexpr’ expansion of ‘fib((n - 1))’
a.cpp:6:15:   in ‘constexpr’ expansion of ‘fib((n - 1))’
a.cpp:6:15:   in ‘constexpr’ expansion of ‘fib((n - 1))’
a.cpp:11:27: error: ‘constexpr’ evaluation depth exceeds maximum of 10 (use
‘-fconstexpr-depth=’ to increase the maximum)
   11 |     constexpr auto i = fib(1);
      |                        ~~~^~~

Reply via email to