public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/48127] New: Program crashes reading a non-aligned variable
@ 2011-03-15  0:01 d.g.gorbachev at gmail dot com
  2011-03-15  8:01 ` [Bug target/48127] " d.g.gorbachev at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2011-03-15  0:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48127

           Summary: Program crashes reading a non-aligned variable
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: d.g.gorbachev@gmail.com
            Target: i686-pc-linux-gnu


Created attachment 23657
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23657
Testcase

(See also: <http://sourceware.org/PR12578>.)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/48127] Program crashes reading a non-aligned variable
  2011-03-15  0:01 [Bug target/48127] New: Program crashes reading a non-aligned variable d.g.gorbachev at gmail dot com
@ 2011-03-15  8:01 ` d.g.gorbachev at gmail dot com
  2011-03-15 10:32 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2011-03-15  8:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48127

--- Comment #1 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com> 2011-03-15 06:22:13 UTC ---
Works when changing the number of elements in baz to 8.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/48127] Program crashes reading a non-aligned variable
  2011-03-15  0:01 [Bug target/48127] New: Program crashes reading a non-aligned variable d.g.gorbachev at gmail dot com
  2011-03-15  8:01 ` [Bug target/48127] " d.g.gorbachev at gmail dot com
@ 2011-03-15 10:32 ` rguenth at gcc dot gnu.org
  2011-03-15 18:09 ` d.g.gorbachev at gmail dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-03-15 10:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48127

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matz at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-03-15 10:27:39 UTC ---
I think the testcase is invalid as you have two definitions of baz which
are not both common.

The vectorizer relies on being able to promote alignment of definitions
which I'm not sure it can do so for commons (it would rely on the linker
choosing the common with the largest alignment).

A testcase that works with -fno-common would be more convincing here ;)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/48127] Program crashes reading a non-aligned variable
  2011-03-15  0:01 [Bug target/48127] New: Program crashes reading a non-aligned variable d.g.gorbachev at gmail dot com
  2011-03-15  8:01 ` [Bug target/48127] " d.g.gorbachev at gmail dot com
  2011-03-15 10:32 ` rguenth at gcc dot gnu.org
@ 2011-03-15 18:09 ` d.g.gorbachev at gmail dot com
  2011-03-16  9:41 ` rguenther at suse dot de
  2014-06-19  5:18 ` d.g.gorbachev at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2011-03-15 18:09 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48127

--- Comment #3 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com> 2011-03-15 18:00:23 UTC ---
I do not agree that the testcase is invalid. As the standart says:

  Common extensions

  Multiple external definitions

     There may be more than one external definition for the identifier of
  an object, with or without the explicit use of the keyword extern; if
  the definitions disagree, or more than one is initialized, the behavior
  is undefined.

According to the Binutils documentation,

  The linker turns a common symbol into a declaration, if there is a
  definition of the same variable.

Also, from Ian Lance Taylor's article [1]:

  5. If A is a strong definition in an object file:

    * If B is a common symbol, then we treat B as an undefined reference.

I think it would be better to fix this problem in the linker. Gold does not
even warn about it!

However, I don't understand why GCC makes baz[8] to have 32 bytes alignment,
while baz[4] has only 4 bytes alignment. It seems to be a GCC bug.

When baz is declared extern in main.c, the generated code is correct, but less
optimal.


1. http://www.airs.com/blog/archives/49


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/48127] Program crashes reading a non-aligned variable
  2011-03-15  0:01 [Bug target/48127] New: Program crashes reading a non-aligned variable d.g.gorbachev at gmail dot com
                   ` (2 preceding siblings ...)
  2011-03-15 18:09 ` d.g.gorbachev at gmail dot com
@ 2011-03-16  9:41 ` rguenther at suse dot de
  2014-06-19  5:18 ` d.g.gorbachev at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: rguenther at suse dot de @ 2011-03-16  9:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48127

--- Comment #4 from rguenther at suse dot de <rguenther at suse dot de> 2011-03-16 09:40:35 UTC ---
On Tue, 15 Mar 2011, d.g.gorbachev at gmail dot com wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48127
> 
> --- Comment #3 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com> 2011-03-15 18:00:23 UTC ---
> I do not agree that the testcase is invalid. As the standart says:
> 
>   Common extensions
> 
>   Multiple external definitions
> 
>      There may be more than one external definition for the identifier of
>   an object, with or without the explicit use of the keyword extern; if
>   the definitions disagree, or more than one is initialized, the behavior
>   is undefined.
> 
> According to the Binutils documentation,
> 
>   The linker turns a common symbol into a declaration, if there is a
>   definition of the same variable.
> 
> Also, from Ian Lance Taylor's article [1]:
> 
>   5. If A is a strong definition in an object file:
> 
>     * If B is a common symbol, then we treat B as an undefined reference.
> 
> I think it would be better to fix this problem in the linker. Gold does not
> even warn about it!
> 
> However, I don't understand why GCC makes baz[8] to have 32 bytes alignment,
> while baz[4] has only 4 bytes alignment. It seems to be a GCC bug.

It's an optimization to ensure accesses larger than 4 do not cross
cacheline boundaries.

Richard.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/48127] Program crashes reading a non-aligned variable
  2011-03-15  0:01 [Bug target/48127] New: Program crashes reading a non-aligned variable d.g.gorbachev at gmail dot com
                   ` (3 preceding siblings ...)
  2011-03-16  9:41 ` rguenther at suse dot de
@ 2014-06-19  5:18 ` d.g.gorbachev at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2014-06-19  5:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48127

Dmitry Gorbachev <d.g.gorbachev at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
      Known to work|                            |4.8.4
         Resolution|---                         |FIXED

--- Comment #5 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com> ---
GCC 4.8.4 (and recent 4.9, 4.10) do not generate SSE instructions for this
testcase.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-06-19  5:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-15  0:01 [Bug target/48127] New: Program crashes reading a non-aligned variable d.g.gorbachev at gmail dot com
2011-03-15  8:01 ` [Bug target/48127] " d.g.gorbachev at gmail dot com
2011-03-15 10:32 ` rguenth at gcc dot gnu.org
2011-03-15 18:09 ` d.g.gorbachev at gmail dot com
2011-03-16  9:41 ` rguenther at suse dot de
2014-06-19  5:18 ` d.g.gorbachev at gmail dot com

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).