Commit d0460ec
authored
[emval] Prevent creating lvalue refs from thin air (#24606)
I'm having trouble reproducing this UB in isolation, but I ran into
issues with garbage values in test_i64_val while making other
innocent-looking changes. I think it might even explain the really weird
bug from
#24577 (comment)
that magically went away after a rebase despite no related changes being
made upstream.
Essentially, because I stupidly used `T&&` in a template, and because
it's [waves around] C++, it got inferred as `unsigned long long &`
instead of the desired `unsigned long long`, so in `.as<T>()` we were
quietly returning an `unsigned long long&` reference to a temporary
`unsigned long long` value on function stack.
Most of the time it somehow still works and, because it's templated,
it's not caught by Clang's "non-const lvalue reference to type"
diagnostic, but under unrelated changes and optimisations it can break
badly.1 parent 273a3fd commit d0460ec
2 files changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
573 | 576 | | |
574 | 577 | | |
575 | 578 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
0 commit comments