https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111160
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |11.5 Last reconfirmed| |2023-08-26 Summary|ICE on assigning volatile |[11/12/13/14 Regression] |through ternary operator |ICE on assigning volatile | |through ternary operator Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Known to work| |5.1.0 Known to fail| |6.1.0 Keywords| |ice-on-invalid-code --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- GCC 5.1.0 and before for C++11: <source>: In function 'void the_func()': <source>:6:19: error: ambiguous overload for 'operator=' (operand types are 'TheClass' and 'volatile TheClass') (false ? x : x) = y; ^ <source>:2:8: note: candidate: TheClass& TheClass::operator=(const TheClass&) <near match> struct TheClass {}; ^ <source>:2:8: note: conversion of argument 1 would be ill-formed: <source>:6:19: error: binding 'volatile TheClass' to reference of type 'const TheClass&' discards qualifiers (false ? x : x) = y; ^ <source>:2:8: note: candidate: TheClass& TheClass::operator=(TheClass&&) <near match> struct TheClass {}; ^ <source>:2:8: note: conversion of argument 1 would be ill-formed: <source>:6:19: error: cannot bind 'volatile TheClass' lvalue to 'TheClass&&' (false ? x : x) = y; ^ For C++98: <source>: In function 'void the_func()': <source>:6:19: error: binding 'volatile TheClass' to reference of type 'const TheClass&' discards qualifiers (false ? x : x) = y; ^ <source>:2:8: note: initializing argument 1 of 'TheClass& TheClass::operator=(const TheClass&)' struct TheClass {}; ^ Confirmed. this is invalid code.