File tree 2 files changed +9
-7
lines changed 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) {
2421
2421
const T &Offset = S.Stk .pop <T>();
2422
2422
const Pointer &Ptr = S.Stk .peek <Pointer>();
2423
2423
2424
- if (!Ptr .isZero ()) {
2424
+ if (!Ptr .isZero () && !Offset. isZero () ) {
2425
2425
if (!CheckArray (S, OpPC, Ptr ))
2426
2426
return false ;
2427
2427
}
@@ -2437,7 +2437,7 @@ inline bool ArrayElemPtrPop(InterpState &S, CodePtr OpPC) {
2437
2437
const T &Offset = S.Stk .pop <T>();
2438
2438
const Pointer &Ptr = S.Stk .pop <Pointer>();
2439
2439
2440
- if (!Ptr .isZero ()) {
2440
+ if (!Ptr .isZero () && !Offset. isZero () ) {
2441
2441
if (!CheckArray (S, OpPC, Ptr ))
2442
2442
return false ;
2443
2443
}
Original file line number Diff line number Diff line change @@ -1196,13 +1196,15 @@ namespace incdecbool {
1196
1196
}
1197
1197
1198
1198
#if __cplusplus >= 201402L
1199
- // / NOTE: The diagnostics of the two interpreters are a little
1200
- // / different here, but they both make sense.
1201
1199
constexpr 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'}}
1205
1202
}
1203
+ namespace externarr {
1204
+ extern int arr[];
1205
+ constexpr int *externarrindex = &arr[0 ]; // / No diagnostic.
1206
+ }
1207
+
1206
1208
1207
1209
namespace StmtExprs {
1208
1210
constexpr int foo () {
You can’t perform that action at this time.
0 commit comments