Skip to content

Commit

Permalink
[clang][Interp] Remove now faulty assertion
Browse files Browse the repository at this point in the history
We can call getBase() for pointers where Base != Offset as well,
for example when we've added a constant to the Offset.
  • Loading branch information
tbaederr committed Feb 28, 2024
1 parent 926a19b commit a2efb68
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion clang/lib/AST/Interp/Pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ class Pointer {
assert(Offset == PastEndMark && "cannot get base of a block");
return Pointer(Pointee, Base, 0);
}
assert(Offset == Base && "not an inner field");
unsigned NewBase = Base - getInlineDesc()->Offset;
return Pointer(Pointee, NewBase, NewBase);
}
Expand Down
6 changes: 6 additions & 0 deletions clang/test/AST/Interp/cxx11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ int array2[recurse2]; // both-warning {{variable length arrays in C++}} \
// both-note {{initializer of 'recurse2' is not a constant expression}} \
// expected-error {{variable length array declaration not allowed at file scope}} \
// ref-warning {{variable length array folded to constant array as an extension}}

struct S {
int m;
};
constexpr S s = { 5 };
constexpr const int *p = &s.m + 1;

0 comments on commit a2efb68

Please sign in to comment.