File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -2421,7 +2421,7 @@ inline bool ArrayElemPtr(InterpState &S, CodePtr OpPC) {
24212421 const T &Offset = S.Stk .pop <T>();
24222422 const Pointer &Ptr = S.Stk .peek <Pointer>();
24232423
2424- if (!Ptr.isZero ()) {
2424+ if (!Ptr.isZero () && !Offset. isZero () ) {
24252425 if (!CheckArray (S, OpPC, Ptr))
24262426 return false ;
24272427 }
@@ -2437,7 +2437,7 @@ inline bool ArrayElemPtrPop(InterpState &S, CodePtr OpPC) {
24372437 const T &Offset = S.Stk .pop <T>();
24382438 const Pointer &Ptr = S.Stk .pop <Pointer>();
24392439
2440- if (!Ptr.isZero ()) {
2440+ if (!Ptr.isZero () && !Offset. isZero () ) {
24412441 if (!CheckArray (S, OpPC, Ptr))
24422442 return false ;
24432443 }
Original file line number Diff line number Diff line change @@ -1196,13 +1196,15 @@ namespace incdecbool {
11961196}
11971197
11981198#if __cplusplus >= 201402L
1199- // / NOTE: The diagnostics of the two interpreters are a little
1200- // / different here, but they both make sense.
12011199constexpr int externvar1 () { // both-error {{never produces a constant expression}}
1202- extern char arr[]; // ref-note {{declared here}}
1203- return arr[0 ]; // ref-note {{read of non-constexpr variable 'arr'}} \
1204- // expected-note {{indexing of array without known bound}}
1200+ extern char arr[]; // both-note {{declared here}}
1201+ return arr[0 ]; // both-note {{read of non-constexpr variable 'arr'}}
12051202}
1203+ namespace externarr {
1204+ extern int arr[];
1205+ constexpr int *externarrindex = &arr[0 ]; // / No diagnostic.
1206+ }
1207+
12061208
12071209namespace StmtExprs {
12081210 constexpr int foo () {
You can’t perform that action at this time.
0 commit comments