[PATCH] D99165: [clang] Fix a crash on checkDestructorReference.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 24 04:50:08 PDT 2021


sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks for digging!



================
Comment at: clang/lib/AST/Type.cpp:2234
     // (C++ [dcl.array]p1).
-    // We don't handle variable arrays (they're not allowed in C++) or
-    // dependent-sized arrays (dependent types are never treated as incomplete).
----------------
hokein wrote:
> This comment is pretty old, and was added in 2dfdb820ca550f75769f6850bc27f825f1dce4f7 in 2009. I don't think this is correct anymore, variable-length array is allowed in C++, and from http://eel.is/c++draft/basic.types.general#5, 
> 
> > an array of unknown bound or of incomplete element type, is an incompletely-defined object type.36 Incompletely-defined object types and cv void are incomplete types
> 
> This comment is pretty old, and was added in 2dfdb820ca550f75769f6850bc27f825f1dce4f7 in 2009. I don't think this is correct anymore

Agree, VLA in C++ were supported in clang in e7545b33ff79 (5 years ago)

> variable-length array is allowed in C++

Not by the standard! It's an extension, copied from gcc.

> an array of unknown bound or of incomplete element type

Yeah, it makes sense to treat VLA like array here.
(I was confused, but "unknown bound" doesn't refer to VLAs, that's rather `extern int x[];` which is `IncompleteArray`)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99165/new/

https://reviews.llvm.org/D99165



More information about the cfe-commits mailing list