This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ Patch] PR 84333 ("[6/7/8 Regression] ICE with ternary operator in template function")
- From: Jason Merrill <jason at redhat dot com>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 13 Feb 2018 11:12:41 -0500
- Subject: Re: [C++ Patch] PR 84333 ("[6/7/8 Regression] ICE with ternary operator in template function")
- Authentication-results: sourceware.org; auth=none
- References: <d8838d77-f124-9c02-d2f5-92baad1baced@oracle.com> <CADzB+2mgj=iNR_agqvXtr6-arASeu3b4cgVUKURrLz1F=4G0LA@mail.gmail.com> <bf2541c2-d521-8a95-6cd0-5986e3d09f62@oracle.com>
On Tue, Feb 13, 2018 at 10:43 AM, Paolo Carlini
<paolo.carlini@oracle.com> wrote:
> On 13/02/2018 15:35, Jason Merrill wrote:
> Thanks. Unfortunately, I don't think I sent a complete solution for these
> issues. In fact we would still ICE on:
>
> template<typename T> int foo()
> {
> return sizeof(T) > 1 ? : 1;
> }
>
> because type_contains_placeholder_p doesn't know how to handle a
> TEMPLATE_TYPE_PARM. In fact, cp_save_expr teaches me something:
>
> tree
> cp_save_expr (tree expr)
> {
> /* There is no reason to create a SAVE_EXPR within a template; if
> needed, we can create the SAVE_EXPR when instantiating the
> template. Furthermore, the middle-end cannot handle C++-specific
> tree codes. */
> if (processing_template_decl)
> return expr;
> return save_expr (expr);
> }
>
> would it be correct to just use it? Or we have to do something more complex?
> Note the issue only affects the GNU-extension with omitted middle operand,
> thus I believe we have *some* leeway...
Hmm, yes, that should work. In a template we're just figuring out the
result type, at instantiation time we'll see the missing middle op
again and can do the right thing. OK.
Jason