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

            Bug ID: 111132
           Summary: Function redeclaration in local scope breaks constant
                    expression evaluation
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

This program

constexpr bool bar(void) {
    return true;
}

constexpr bool foo() {
    constexpr bool bar(void);
    return bar();
}

static_assert( foo() );


is accepted in Clang, but not in GCC, which prints


error: non-constant condition for static assertion
   10 | static_assert( foo() );
      |                ~~~^~
<source>:10:19:   in 'constexpr' expansion of 'foo()'
<source>:7:15: error: 'constexpr bool bar()' used before its definition
    7 |     return bar();
      |            ~~~^~

Online demo: https://godbolt.org/z/3PvoEx61x

Reply via email to