[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

A. Jiang via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 31 19:02:17 PDT 2025


frederick-vs-ja wrote:

> (LMK if I've got that wrong!) Given that, how is the C11 change a breaking change? It seems like the C99 rule was just bogus, and we should forget it ever existed?

IIUC, the "breaking change" is that in C99 a pointer value to a temporary array element never becomes indeterminate (despite access through it raising UB), but in C11 it does.

E.g.
```C
struct S { int a[1]; };
struct S fun(void) {
  return (struct S){0};
}

int main(void) {
  int* p = fun().a;
  int m = *p; // UB in C99 and C11
  *p += 42;   // UB in C99 and C11

  *p;         // UB in C11, but OK in C99?
  int* q = p; // q is more indeterminate in C11?
}
```

https://github.com/llvm/llvm-project/pull/133472


More information about the cfe-commits mailing list