Skip to content

Commit a2efb68

Browse files
committed
[clang][Interp] Remove now faulty assertion
We can call getBase() for pointers where Base != Offset as well, for example when we've added a constant to the Offset.
1 parent 926a19b commit a2efb68

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

clang/lib/AST/Interp/Pointer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ class Pointer {
215215
assert(Offset == PastEndMark && "cannot get base of a block");
216216
return Pointer(Pointee, Base, 0);
217217
}
218-
assert(Offset == Base && "not an inner field");
219218
unsigned NewBase = Base - getInlineDesc()->Offset;
220219
return Pointer(Pointee, NewBase, NewBase);
221220
}

clang/test/AST/Interp/cxx11.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ int array2[recurse2]; // both-warning {{variable length arrays in C++}} \
2222
// both-note {{initializer of 'recurse2' is not a constant expression}} \
2323
// expected-error {{variable length array declaration not allowed at file scope}} \
2424
// ref-warning {{variable length array folded to constant array as an extension}}
25+
26+
struct S {
27+
int m;
28+
};
29+
constexpr S s = { 5 };
30+
constexpr const int *p = &s.m + 1;

0 commit comments

Comments
 (0)