public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: paul@codesourcery.com (Paul Brook)
Cc: gcc-patches@gcc.gnu.org,
	richard.guenther@gmail.com (Richard Guenther),
	       stevenb.gcc@gmail.com (Steven Bosscher),
	dnovillo@google.com,        froydnj@codesourcery.com,
	mark@codesourcery.com (Mark Mitchell)
Subject: Re: [PATCH] [4.5 regression] C++ ignores some aligned attributes
Date: Wed, 04 Aug 2010 16:42:00 -0000	[thread overview]
Message-ID: <201008041642.o74GgXQw014933@d12av02.megacenter.de.ibm.com> (raw)
In-Reply-To: <201008041603.56920.paul@codesourcery.com> from "Paul Brook" at Aug 04, 2010 04:03:56 PM

Paul Brook wrote:
> > Well, the only thing my patch does is to revert behavior back to what it
> > was in 4.4 and earlier, after having been (clearly inadvertently) changed
> > by an unrelated patch.  At least Firefox relies on that behavior; Firefox
> > builds would certainly break if we add the error you suggest ...
> 
> I'd argue that this is a feature.  Code already broke (PR45112) once due to 
> mismatched alignment assumptions, so who knows what other bugs are lurking 
> behind this mismatch.  Better to fail at compile time than runtime.

With this patch to fix PR45112 (which restores prior behavior), there *is*
no bug lurking in Firefox; the Firefox code seems perfectly fine to me,
and I see no reason to deliberately break Firefox builds here.

PR45112 did not break because of mismatched alignment attributes; rather
it broke because the compiler *ignored* the (one) alignment attribute on the
definition, due to an unintended effect of the patch moving bits around.

There is no code in Firefox that relies on having an alignment attribute
visible on the declaration.  There certainly is the (implicit) assumption
that all JSVAL pointers must be 8 byte aligned, but this is not really
up to the compiler to enforce (most such pointers come from malloc anyway);
it is a requirement upon users of that interface.  (Which they tried to
satisfy using an aligned attibute -- which was then ignored due to the
GCC bug.)

> It seems rather inconsistent to require any particular behavior in the 
> presence of this inconsistency, but not provide a diagnostic for all the other 
> closely related cases that we know are still going to break. If nothing else 
> this seems like a missed optimization opportunity.

I'm not sure I agree that there is an inconsistency.  In general, in C
(or C++), declarations need not necessarily agree on each property they
specify; for example, you can have a declaration with "static" and one
without "static" for the same function.  These properties are then merged.
I do not see why aligned attributes should necessarily be different here;
introducing this as requirement seems to be a change with the potential to
break existing code bases that otherwise wouldn't have any problems.

Now, this property does of course give rise to the possibility that it
can be used in incorrect ways that introduce bugs.  But I don't agree
that the Firefox usage is of that type.  It simply requests that the
variable is actually allocated using stricter alignment requirements
than would otherwise be the case.  (Note that you could have the same
effect by specifying that extra alignment in a linker script!)


I guess I could see an argument to be made for a diagnostic if the alignment
at the definition is *less* strict than the one at some other declaration,
and we know about it at the point.  This diagnostic in fact would not break
Firefox either, because that's not the case there.

However, as Mark mentioned, that diagnostic wouldn't be a sure way to
recognize all instances, because that other declaration might not
even be visible at the site of the definition ...


[ In either case, that seems a completely separate argument from whether
the original patch in this thread ought to be applied -- which it of
course already is.  In my mind that patch fixes a wrong-code regression
by restoring prior behaviour.  If we decide that additional diagnostics
are useful in certain cases, that would be an enhancement on top.  ]

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com

  reply	other threads:[~2010-08-04 16:42 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-08 15:32 [PATCH] fix arm neon ICE by widening tree_type's precision field Nathan Froyd
2009-06-08 17:11 ` Richard Guenther
2009-06-08 18:04 ` Paolo Bonzini
2009-06-08 20:28   ` Nathan Froyd
2009-06-08 20:32     ` Steven Bosscher
2009-06-09  6:36     ` Paolo Bonzini
2009-06-09 14:54       ` Nathan Froyd
2009-06-09 15:00         ` Richard Guenther
2009-06-09 15:07           ` Richard Guenther
2009-06-09 15:44           ` Steven Bosscher
2009-06-10  2:50           ` Eric Botcazou
2009-06-09 15:40         ` Steven Bosscher
2009-06-09 15:53           ` Richard Guenther
2009-06-09 16:31             ` Nathan Froyd
2009-06-09 16:34               ` Richard Guenther
2009-06-09 16:36               ` Diego Novillo
2009-06-09 17:30               ` Paolo Bonzini
2010-07-28 19:01               ` [4.5 regression] C++ ignores some aligned attributes (Re: [PATCH] fix arm neon ICE by widening tree_type's precision field) Ulrich Weigand
2010-07-28 19:40                 ` Richard Guenther
2010-07-29 12:29                   ` [4.5 regression] C++ ignores some aligned attributes (Re: [PATCH] fix arm neon ICE by widening tree_type's precision field Ulrich Weigand
2010-07-28 22:07                 ` [PATCH] [4.5 regression] C++ ignores some aligned attributes Ulrich Weigand
2010-07-30 16:00                   ` Ulrich Weigand
2010-07-30 16:22                     ` Richard Guenther
2010-07-30 16:22                       ` Ulrich Weigand
2010-07-31 17:45                   ` Eric Botcazou
2010-07-31 19:38                     ` Ulrich Weigand
2010-08-04 14:03                   ` Paul Brook
2010-08-04 14:19                     ` Ulrich Weigand
2010-08-04 14:27                       ` Mark Mitchell
2010-08-04 15:04                       ` Paul Brook
2010-08-04 16:42                         ` Ulrich Weigand [this message]
2010-08-04 15:33                       ` Martin Sebor
2010-08-04 15:47                         ` Mark Mitchell
2010-08-05  9:02                           ` Martin Sebor
2009-06-08 19:40 ` [PATCH] fix arm neon ICE by widening tree_type's precision field Joseph S. Myers
2009-06-08 19:52   ` Daniel Jacobowitz
2009-06-08 20:12     ` Andrew Pinski
2009-06-08 20:20     ` Jakub Jelinek
2009-06-08 20:33       ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201008041642.o74GgXQw014933@d12av02.megacenter.de.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=dnovillo@google.com \
    --cc=froydnj@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mark@codesourcery.com \
    --cc=paul@codesourcery.com \
    --cc=richard.guenther@gmail.com \
    --cc=stevenb.gcc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).