This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [libcpp+C++ PATCH] Fix -Wempty-body C++ warning (PR c++/36478)


On Mon, Nov 10, 2008 at 11:33:26AM -0800, Mark Mitchell wrote:
> >From a technical perspective, I think this patch makes sense.  In
> particular, using a flag from the preprocessor, rather than poking at
> location information, seems OK to me.
> 
> But, do we really want to warn about:
> 
>   while (0);
> 
> but not:
> 
>   while (0) ;
> 
> ?

A lot of people write for (a = b; something; somethingelse) ;
or for (a = b; something; somethingelse)/* Empty */;
if everything needed for the loop happens in the condition
or increment or both.  I don't think we want to add extra cases where
we want to warn, it will make the warning completely useless.

> That seems surprising to me.
> 
> I can understand not warning about:
> 
>   while (0)
>     ;

That's just one of the possible styles people use to mark an empty body
of a loop.  A space is another one, a comment another one, a macro another
one.  The alternative is IMHO just reverting Mike's 2007-05-07 changes.

> If we're using the single space as a way of making -save-temps work
> (because an empty macro gets replaced with a space), I think that's just
> as fragile a hack as we had before.  If we really need to make

Why?  Space is used by the preprocessor generally as a token separator
if whitespace is needed and we don't preserve columns with -E anyway.

> -save-temps work, then we need -save-temps to emit something explicit to
> mark the presence of the macro.
> 
> But, I also don't see it as a crisis if -save-temps doesn't work in this
> particular case.  Once we decide that the presence of a macro is a
> significant fact, we also accept that preprocessing the code is going to
> result in a change.  That might argue that using the presence of a macro
> is a mistake...

-save-temps is perhaps not 100% important, though many people will moan, but
ccache is important for a lot of users.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]