File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -394,6 +394,22 @@ constexpr bool may_overlap_different_encoding[] =
394394
395395}
396396
397+ constexpr const char *getStr () {
398+ return " abc" ; // expected-note {{repeated evaluation of the same literal expression can produce different objects}}
399+ }
400+ constexpr int strMinus () {
401+ (void )(getStr () - getStr ()); // expected-note {{arithmetic on addresses of potentially overlapping literals has unspecified value}} \
402+ // cxx11-warning {{C++14 extension}}
403+ return 0 ;
404+ }
405+ static_assert (strMinus() == 0 , " " ); // expected-error {{not an integral constant expression}} \
406+ // expected-note {{in call to}}
407+
408+ constexpr int a = 0 ;
409+ constexpr int b = 1 ;
410+ constexpr int n = &b - &a; // expected-error {{must be initialized by a constant expression}} \
411+ // expected-note {{arithmetic involving unrelated objects '&b' and '&a' has unspecified value}}
412+
397413namespace MaterializeTemporary {
398414
399415constexpr int f (const int &r) { return r; }
You can’t perform that action at this time.
0 commit comments