|
|
От: |
T4r4sB
|
|
| Дата: | 27.04.23 17:21 | ||
| Оценка: | |||
То есть этот код содержит УБ?Modifying a const object through a non-const access path and referring to a volatile object through a non-volatile glvalue results in undefined behavior.
int g=0;
int bar() {
++g;
return g;
}
int foo(const int& a) {
return a + bar() + a;
}
int main() {
printf("%i\n", foo(g));
}