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

            Bug ID: 108218
           Summary: [12 Regression] Constant arguments in the new
                    expression is not checked in unevaluated operand
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: StevenSun2021 at hotmail dot com
  Target Milestone: ---

```
int main() {
    decltype(new int[-1]) a; // compiles with g++-12! <- regression here
                             // does not compile with g++-11


    auto b = new int[-1];    // does not compile with g++-12
                             // does not compile with g++-11
}
```
https://godbolt.org/z/aMGMrbfrd


expected behavior:
if, after conversion to std::size_t, the first dimension is a core constant
expression and it is potentially evaluated, the program is ill-formed.
https://en.cppreference.com/w/cpp/language/new

gcc(<=11.3 (current version)) and clang(>=3) does this check.

Reply via email to