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: [C++ PATCH] Fix regressions introduced by my PR34094 fix (PR c++/34238, c++/34340)


On Fri, Dec 07, 2007 at 12:52:31PM -0800, Mark Mitchell wrote:
> Jakub Jelinek wrote:
> 
> >>   namespace { struct A { static int i; }; }
> >>   static int foo() { return A::i; }
> >>
> >> the program is still erroneous, even though the compiler may likely
> >> optimize away foo, and the reference to A::i.
> > 
> > That's true, but the standard explicitly says the diagnostic is not
> > required.
> 
> It does?  Where?  (I'm not disagreeing, I'm just surprised, and I
> couldn't find a pointer.)

[class.static.data]/5:
"There shall be exactly one definition of a static data member that is used in a program; no diagnostic is required; see 3.2."

The patch I posted last Wednesday diagnosed the errors basically for the
same stuff that ld would diagnose it, if anon namespace was not involved.
When all uses are optimized out, etc., ld will not error nor warn either.

> > that should be warned about.  If we have some bit which we can really rely
> > on to be set reliably for these purposes, then the warning can be precise,
> > but TREE_USED is unfortunately not it.
> 
> TREE_USED should be accurate.  It should tell us whether or not a thing
> was used by the input.  If TREE_USED is not set when it should be, or
> set when it shouldn't be, we have a problem.

But it is set e.g. when seen in sizeof as shown on that boost snippet.

> > I'm afraid I don't know the FE enough to further improve this warning
> > without breaking valid programs, so the other possibility for me is just to
> > back out the original patch and leave this can of worms to you/Jason.
> 
> All right; let's revert your original patch, then.  AIUI, that patch
> fixed an accepts-invalid problem; that's better than rejects-valid problems.

If you prefer that, here is a patch I've bootstrapped/regtested on
x86_64-linux.

	Jakub

Attachment: Z93
Description: Text document


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