Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/AST/ByteCode/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2535,7 +2535,7 @@ inline bool ArrayDecay(InterpState &S, CodePtr OpPC) {
if (!CheckRange(S, OpPC, Ptr, CSK_ArrayToPointer))
return false;

if (Ptr.isRoot() || !Ptr.isUnknownSizeArray() || Ptr.isDummy()) {
if (Ptr.isRoot() || !Ptr.isUnknownSizeArray()) {
S.Stk.push<Pointer>(Ptr.atIndex(0));
return true;
}
Expand Down
9 changes: 9 additions & 0 deletions clang/test/AST/ByteCode/arrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,15 @@ namespace Incomplete {
constexpr int C = *F.a; // both-error {{must be initialized by a constant expression}} \
// both-note {{array-to-pointer decay of array member without known bound}}

struct X {
int a;
int b[];
};
extern X x;
constexpr int *xb = x.b; // both-error {{must be initialized by a constant expression}} \
// both-note {{array-to-pointer decay of array member without known bound}}


/// These are from test/SemaCXX/constant-expression-cxx11.cpp
extern int arr[];
constexpr int *c = &arr[1]; // both-error {{must be initialized by a constant expression}} \
Expand Down