public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/56293] Segfault when trying to access pass-by-reference value of a not-word-aligned REAL(16) /  -fno-align-commons
Date: Tue, 12 Feb 2013 12:40:00 -0000	[thread overview]
Message-ID: <bug-56293-4-Geq9bvewLn@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-56293-4@http.gcc.gnu.org/bugzilla/>


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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> 2013-02-12 12:39:55 UTC ---
(In reply to comment #3)
> Also occurs if one calls ("call foo(p)"):
>       subroutine foo(x)
>         real(16) :: x, y
>         y = x  ! FAILS HERE
>         ! print *, y
>       end subroutine foo
> instead of "print *, p".
> 
> 
> The bug is probably somewhere in gcc/fortran/trans-common.c's. For instance at
> build_common_decl, which uses:
> 
>       if (!com->is_bind_c)
>         DECL_ALIGN (decl) = BIGGEST_ALIGNMENT;
> 
> or/and in "build_field", which has:
> 
>   known_align = (offset & -offset) * BITS_PER_UNIT;
>   if (known_align == 0 || known_align > BIGGEST_ALIGNMENT)
>     known_align = BIGGEST_ALIGNMENT;
> 
>   desired_align = update_alignment_for_field (rli, field, known_align);
>   if (desired_align > known_align)
>        (field) = 1;
> 
> or …

The problem is that you are in no way dealing with the interface
mismatches in a correct way.  Not that I think you can.

I suggest to remove -fno-align-commons.

Or is there a fortran way to say that

       subroutine foo(x)
         real(16) :: x, y

may receive an unaligned x?

It seems to me that with an -fno-align-commons common you cannot do very
much.  You'd have to make sure to always access it though the common
and never pass pieces of it to another function (maybe the frontend could
warn about this).  Can you specify -fno-align-commons per common block?


  parent reply	other threads:[~2013-02-12 12:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-12  9:51 [Bug fortran/56293] New: I/O: Segfault in write_float when trying to print " burnus at gcc dot gnu.org
2013-02-12  9:52 ` [Bug fortran/56293] " burnus at gcc dot gnu.org
2013-02-12 10:23 ` tobi at gcc dot gnu.org
2013-02-12 12:35 ` [Bug fortran/56293] Segfault when trying to access pass-by-reference value of " burnus at gcc dot gnu.org
2013-02-12 12:40 ` rguenth at gcc dot gnu.org [this message]
2013-02-12 13:07 ` burnus at gcc dot gnu.org
2013-03-10 15:32 ` tkoenig at gcc dot gnu.org
2013-03-11  0:16 ` tobi at gcc dot gnu.org
2014-01-07 14:04 ` dominiq at lps dot ens.fr

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=bug-56293-4-Geq9bvewLn@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).