[Bug c++/54543] Expression (condition ? array : throw expr)[index] fails to compile

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Mar 25 17:34:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54543

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The code is valid.

The workaround we use in the library is to use the comma operator:

        return ((0 <= n && n < 10) ? arr : (throw "error", arr))[n];



More information about the Gcc-bugs mailing list