You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
std::string_view defaultparam4(std::string_view s [[clang::lifetimebound]] = std::string()); // #def6
120
+
121
+
constint*test_default_args() {
122
+
constint *c = defaultparam1(); // expected-warning {{temporary whose address is used as value of local variable 'c' will be destroyed at the end of the full-expression}} expected-note@#def1 {{initializing parameter 'def1' with default argument}}
123
+
A a = A(""); // expected-warning {{temporary whose address is used as value of local variable 'a' will be destroyed at the end of the full-expression}} expected-note@#def3 {{initializing parameter 'def3' with default argument}}
124
+
constint &s = defaultparam2(); // expected-warning {{temporary bound to local reference 's' will be destroyed at the end of the full-expression}} expected-note@#def4 {{initializing parameter 'def4' with default argument}}
125
+
constint &t = defaultparam3(); // expected-warning {{temporary bound to local reference 't' will be destroyed at the end of the full-expression}} expected-note@#def4 {{initializing parameter 'def4' with default argument}} expected-note@#def5 {{initializing parameter 'def5' with default argument}}
126
+
constint &u = defaultparam_array(); // expected-warning {{temporary bound to local reference 'u' will be destroyed at the end of the full-expression}} expected-note@#def2 {{initializing parameter 'p' with default argument}}
127
+
int local;
128
+
constint &v = defaultparam2(local); // no warning
129
+
constint &w = defaultparam2(1); // expected-warning {{temporary bound to local reference 'w' will be destroyed at the end of the full-expression}}
130
+
int x = defaultparam2(1); // FIXME: This should warn
131
+
x = defaultparam2(1); // FIXME: This should warn
132
+
if (false) {
133
+
return &defaultparam2(); // expected-warning {{returning address of local temporary object}}
134
+
}
135
+
if (false) {
136
+
return &defaultparam2(0); // expected-warning {{returning address of local temporary object}} expected-note@#def4 {{initializing parameter 'def4' with default argument}}
137
+
}
138
+
std::string_view sv = defaultparam4(); // expected-warning {{temporary whose address is used as value of local variable 'sv' will be destroyed at the end of the full-expression}} expected-note@#def6 {{initializing parameter 's' with default argument}}
139
+
returnnullptr;
140
+
}
141
+
}
142
+
110
143
namespacep0936r0_examples {
111
144
std::string_view s = "foo"s; // expected-warning {{temporary}}
0 commit comments