[Bug c++/87724] New: gcc allows narrowing conversions in converted constant expressions

blitzrakete at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Oct 24 09:32:00 GMT 2018


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

            Bug ID: 87724
           Summary: gcc allows narrowing conversions in converted constant
                    expressions
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: blitzrakete at gmail dot com
  Target Milestone: ---

Compiled with -std=c++17 (https://godbolt.org/z/fO32Pd)

int main() {
  static_assert(2); // ill-formed, gcc accepts
  if constexpr (2); // ill-formed, gcc accepts
}

2 doesn't fit in a bool, and as such it is a narrowing conversion and fails to
be a "contextually converted constant expression of type bool" as per
[expr.const]p5.


More information about the Gcc-bugs mailing list