Skip to content

Don't diagnose an ill-formed global array as being a VLA #88608

@Endilll

Description

@Endilll

That's a FIXME Richard left in CWG367 test. I'm making an issue out of it, because DR test suite is moving away from using array sizes as a C++98-compatible context requiring a constant expression. https://godbolt.org/z/bj85KWYcq

namespace cwg367 { // cwg367: yes
  // FIXME: These diagnostics are terrible. Don't diagnose an ill-formed global
  // array as being a VLA!
  int a[true ? throw 0 : 4];
  // expected-error@-1 {{variable length arrays in C++ are a Clang extension}}
  // expected-error@-2 {{variable length array declaration not allowed at file scope}}
  int b[true ? 4 : throw 0];
  // cxx98-error@-1 {{variable length arrays in C++ are a Clang extension}}
  // cxx98-error@-2 {{variable length array folded to constant array as an extension}}
  int c[true ? *new int : 4];
  // expected-error@-1 {{variable length arrays in C++ are a Clang extension}}
  //   expected-note@-2 {{read of uninitialized object is not allowed in a constant expression}}
  // expected-error@-3 {{variable length array declaration not allowed at file scope}}
  int d[true ? 4 : *new int];
  // cxx98-error@-1 {{variable length arrays in C++ are a Clang extension}}
  // cxx98-error@-2 {{variable length array folded to constant array as an extension}}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions