https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102223
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Federico Kircheis from comment #0) > Normally life-extension would kick in, but because we added an unnecessary > static_cast, it does not kick in and v is a dangling reference. I assume you already know this, but the original testcase in comment 0 is perfectly valid. The static_cast creates a new temporary, which *does* get its lifetime extended.