C++ warnings vs. errors

Mark Mitchell mark@codesourcery.com
Thu Jun 19 00:27:00 GMT 2008


Jonathan Wakely wrote:

> Could a C++ maintainer please review this patch to turn most pedwarns
> into permerrors.

This patch is OK, with minor nits below.  Thanks for working on this!

> The interesting cases are:
> * when 'main' is declared without a return type. I split one case into
> a permerror and pedwarn.

I think that's OK.

> * Should it really be a hard error for a class to declare itself as a
> friend? I don't think it's expressly forbidden
> e.g. class A { friend class A; };
> I changed this to a permerror, restoring the old  behaviour.

I think this should just be a warning.  I can't find anything in the WP 
that says this is invalid.  (That's why I try to cite the WP when making 
changes -- so that we can go back and check later!)  Please change it to 
a warning.

> * I don't think the pedwarn in joust() in cp/call.c should be a
> permerror, is this a GNU extension?
> 	  if (warn)
> 	    {
> 	      pedwarn ("\
> ISO C++ says that these are ambiguous, even \
> though the worst conversion for the first is better than \
> the worst conversion for the second:");
> 	      print_z_candidate (_("candidate 1:"), w);
> 	      print_z_candidate (_("candidate 2:"), l);
> 	    }

Yes, that is a historical GNU extension.  I think this should just be a 
warning, given that the whole section of code is guarded with !pedantic.

> * I don't know if these in cp/typeck.c should be permerrors, DTRT
> implies not, but should tf_error be changed to tf_warning?

I think "DTRT" here means "do what whoever wrote this code thinks the 
standard should say" not "do what the standard says".  Please make these 
permerrors.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713



More information about the Gcc mailing list