[PATCH, C++] Warn on redefinition of builtin functions (PR c++/71973)

Jason Merrill jason@redhat.com
Tue Nov 1 15:02:00 GMT 2016


On 10/17/2016 03:18 PM, Bernd Edlinger wrote:
> Regarding this hunk:
>
>         /* Whether or not the builtin can throw exceptions has no
>           bearing on this declarator.  */
> -      TREE_NOTHROW (olddecl) = 0;
> +      TREE_NOTHROW (olddecl) = TREE_NOTHROW (newdecl);
>
> You may ask, why the old code was working most of the time.
> I think, usually, when types_match == true, there happens another
> assignment to TREE_NOTHROW, later in that function around line 2183:
>
>        /* Merge the type qualifiers.  */
>        if (TREE_READONLY (newdecl))
>          TREE_READONLY (olddecl) = 1;
>        if (TREE_THIS_VOLATILE (newdecl))
>          TREE_THIS_VOLATILE (olddecl) = 1;
>        if (TREE_NOTHROW (newdecl))
>          TREE_NOTHROW (olddecl) = 1;
>
> This is in a big "if (types_match)", so I think that explains,
> why the old code did work normally, and why it fails if the
> parameter don't match, but I still have no idea what to say
> in the comment, except that the code should exactly do what
> the comment above says.

I think a better fix would be to add a copy of TREE_NOTHROW to the else 
block of the if (types_match), to go with the existing copies of 
TREE_READONLY and TREE_THIS_VOLATILE.  But yes, duplicate_decls is a mess.

Jason



More information about the Gcc-patches mailing list