[PATCH] PR c++/10031: Exception lists on builtins

Roger Sayle roger@www.eyesopen.com
Thu Mar 13 01:51:00 GMT 2003


On Wed, 12 Mar 2003, Jason Merrill wrote:
> > The one line solution is to avoid comparing exception lists when
> > both functions are marked nothrow...
>
> I don't think this is the right solution, however.  Both declarations of
> vprintf() in the source are marked throw(), so there should be no conflict.
> The bug is that the throw() specifier on the first declaration is being
> discarded.

Hi Jason,

You're forgetting that there's also the anticipated DECL created by
the built-ins code.  This built-in decl is marked DECL_ANTICIPATED
and has the TREE_NOTHROW flag set, but has an empty exceptions list.

When the first declaration in the user source code is encountered,
the types are compared to the C++ built-in's type, and if they match
the original type is retained, i.e. without an exception list.  But,
for example, the source line is updated.

When the second declaration is encountered, it is compared to the
previous prototype, using the original builtin's type.  However
this time, the DECL_SOURCE_LINE of the previous definition is no
longer zero, so we notice the difference in the ways that the nothrow
attribute is recorded.


If you don't believe me, you can set a breakpoint on duplicate_decls,
and see that it's getting called twice, i.e. vprintf is predeclared
prior to either of the declarations in the user's source code.

Roger
--



More information about the Gcc-patches mailing list