public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/50273] New: [4.5/4.6/4.7 Regression] -Walign-commons no longer effective
@ 2011-09-02 10:03 burnus at gcc dot gnu.org
  2011-09-02 10:11 ` [Bug fortran/50273] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-09-02 10:03 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50273
           Summary: [4.5/4.6/4.7 Regression] -Walign-commons no longer
                    effective
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


Motivated by the thread:
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/1f5e2018f744e5c6


With gfortran 4.4, one got the warning:

  common /global_var/ a, b, c
                     1
Warning: COMMON 'global_var' at (1) requires 3 bytes of padding at start;
reorder elements or use -fno-align-commons


However, with gfortran 4.5/4.6/4.7, it compiles without warning - not even with
-Walign-commons


Note: In 4.5 there was a change in how padding works. Before, the padding was
added before the "too short" variable, now it is added after the variable. The
advantage is a better compatibility with C struct and for common blocks of
different length in different scopes (which is valid for blank commons).
Cf. http://gcc.gnu.org/gcc-4.5/changes.html#Fortran

I assume that this change broke the test.

Example (cf. link for a longer, C+Fortran example):

subroutine test()
   character :: a
   integer   :: b
   character :: c
   common /global_var/ a, b, c
   print *, a, b, c
end subroutine test


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

* [Bug fortran/50273] [4.5/4.6/4.7 Regression] -Walign-commons no longer effective
  2011-09-02 10:03 [Bug fortran/50273] New: [4.5/4.6/4.7 Regression] -Walign-commons no longer effective burnus at gcc dot gnu.org
@ 2011-09-02 10:11 ` rguenth at gcc dot gnu.org
  2011-09-02 10:12 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-09-02 10:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-09-02
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-09-02 10:11:32 UTC ---
> ./f951 -quiet t.f90 -Wpadded
f951: warning: padding struct size to alignment boundary [-Wpadded]
f951: warning: padding struct to align 'pending' [-Wpadded]
f951: warning: padding struct size to alignment boundary [-Wpadded]
t.f90: In function 'test':
t.f90:1:0: warning: padding struct size to alignment boundary [-Wpadded]

Note that suggesting -fno-align-commons shouldn't be done - using it
can severely reduce performance.

Not sure where the first three warnings come from - probably from frontend
generated entities which are not detected as "builtin"

      if (DECL_SOURCE_LOCATION (field) != BUILTINS_LOCATION)
        warning (OPT_Wpadded, "padding struct to align %q+D", field);

  if (TREE_CONSTANT (unpadded_size)
      && simple_cst_equal (unpadded_size, TYPE_SIZE (rli->t)) == 0
      && input_location != BUILTINS_LOCATION)
    warning (OPT_Wpadded, "padding struct size to alignment boundary");


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

* [Bug fortran/50273] [4.5/4.6/4.7 Regression] -Walign-commons no longer effective
  2011-09-02 10:03 [Bug fortran/50273] New: [4.5/4.6/4.7 Regression] -Walign-commons no longer effective burnus at gcc dot gnu.org
  2011-09-02 10:11 ` [Bug fortran/50273] " rguenth at gcc dot gnu.org
@ 2011-09-02 10:12 ` rguenth at gcc dot gnu.org
  2011-09-02 12:57 ` burnus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-09-02 10:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.5.4


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

* [Bug fortran/50273] [4.5/4.6/4.7 Regression] -Walign-commons no longer effective
  2011-09-02 10:03 [Bug fortran/50273] New: [4.5/4.6/4.7 Regression] -Walign-commons no longer effective burnus at gcc dot gnu.org
  2011-09-02 10:11 ` [Bug fortran/50273] " rguenth at gcc dot gnu.org
  2011-09-02 10:12 ` rguenth at gcc dot gnu.org
@ 2011-09-02 12:57 ` burnus at gcc dot gnu.org
  2011-09-07 17:12 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-09-02 12:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-09-02 12:57:03 UTC ---
(In reply to comment #1)
> > ./f951 -quiet t.f90 -Wpadded
> Note that suggesting -fno-align-commons shouldn't be done - using it
> can severely reduce performance.

But to be 100% Fortran standard conforming, one has to use -fno-align-commons,
if I recall correctly. I think the standard demands that the memory is
contiguously, though at the moment, I fail to come up with a
standard-conforming code which would run into issues with -falign-commons (i.e.
the default) - at least after the 4.5 change.

(Side note: The Intel compiler has a similar option (-(no)align): "By default,
no padding is added to common blocks but padding is added to structures.".)

 * * *

Regarding -Wpadded: I have not thoroughly investigated. What puzzles me is the
string "pending" as I could not find the string anywhere.

 * * *

Regarding the missing front-end warning: The following seems to work (only
lightly tested):

--- a/gcc/fortran/trans-common.c
+++ b/gcc/fortran/trans-common.c
@@ -1069,3 +1069,2 @@ translate_common (gfc_common_head *common, gfc_symbol
*var_list)
   unsigned HOST_WIDE_INT align;
-  unsigned HOST_WIDE_INT max_align;
   bool saw_equiv;
@@ -1076,3 +1075,2 @@ translate_common (gfc_common_head *common, gfc_symbol
*var_list)
   align = 1;
-  max_align = 1;
   saw_equiv = false;
@@ -1119,3 +1117,3 @@ translate_common (gfc_common_head *common, gfc_symbol
*var_list)

-         if (offset & (max_align - 1))
+         if (offset)
            {
@@ -1142,4 +1140,2 @@ translate_common (gfc_common_head *common, gfc_symbol
*var_list)
          current_offset += offset;
-         if (max_align < align)
-           max_align = align;


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

* [Bug fortran/50273] [4.5/4.6/4.7 Regression] -Walign-commons no longer effective
  2011-09-02 10:03 [Bug fortran/50273] New: [4.5/4.6/4.7 Regression] -Walign-commons no longer effective burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-09-02 12:57 ` burnus at gcc dot gnu.org
@ 2011-09-07 17:12 ` jakub at gcc dot gnu.org
  2011-10-10  6:54 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-09-07 17:12 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |jakub at gcc dot gnu.org


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

* [Bug fortran/50273] [4.5/4.6/4.7 Regression] -Walign-commons no longer effective
  2011-09-02 10:03 [Bug fortran/50273] New: [4.5/4.6/4.7 Regression] -Walign-commons no longer effective burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2011-09-07 17:12 ` jakub at gcc dot gnu.org
@ 2011-10-10  6:54 ` burnus at gcc dot gnu.org
  2011-10-11  9:59 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-10-10  6:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-10-10 06:54:23 UTC ---
The following patch was committed with the wrong PR number:


Author: burnus
Date: Sun Oct  9 19:37:47 2011
New Revision: 179729

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179729
Log:
2011-10-09  Tobias Burnus  <burnus@net-b.de>

        PR fortran/45044
        * trans-common.c (translate_common): Fix -Walign-commons
        check.

2011-10-09  Tobias Burnus  <burnus@net-b.de>

        PR fortran/45044
        * gfortran.dg/common_14.f90: Compile with -Wno-align-commons.
        * gfortran.dg/common_16.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/common_16.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-common.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/common_14.f90


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

* [Bug fortran/50273] [4.5/4.6/4.7 Regression] -Walign-commons no longer effective
  2011-09-02 10:03 [Bug fortran/50273] New: [4.5/4.6/4.7 Regression] -Walign-commons no longer effective burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2011-10-10  6:54 ` burnus at gcc dot gnu.org
@ 2011-10-11  9:59 ` burnus at gcc dot gnu.org
  2011-10-11 12:34 ` burnus at gcc dot gnu.org
  2011-10-11 12:34 ` burnus at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-10-11  9:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-10-11 09:59:22 UTC ---
Author: burnus
Date: Tue Oct 11 09:59:18 2011
New Revision: 179794

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179794
Log:
2011-10-11  Tobias Burnus  <burnus@net-b.de>

       PR fortran/50273
       * trans-common.c (translate_common): Fix -Walign-commons check.

2011-10-11  Tobias Burnus  <burnus@net-b.de>

       PR fortran/50273
       * gfortran.dg/common_16.f90: New.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/common_16.f90
Modified:
    branches/gcc-4_6-branch/gcc/fortran/ChangeLog
    branches/gcc-4_6-branch/gcc/fortran/trans-common.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/50273] [4.5/4.6/4.7 Regression] -Walign-commons no longer effective
  2011-09-02 10:03 [Bug fortran/50273] New: [4.5/4.6/4.7 Regression] -Walign-commons no longer effective burnus at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2011-10-11  9:59 ` burnus at gcc dot gnu.org
@ 2011-10-11 12:34 ` burnus at gcc dot gnu.org
  2011-10-11 12:34 ` burnus at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-10-11 12:34 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-10-11 12:34:36 UTC ---
FIXED on the trunk (4.7) and on the 4.5 and 4.6 branches.


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

* [Bug fortran/50273] [4.5/4.6/4.7 Regression] -Walign-commons no longer effective
  2011-09-02 10:03 [Bug fortran/50273] New: [4.5/4.6/4.7 Regression] -Walign-commons no longer effective burnus at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2011-10-11 12:34 ` burnus at gcc dot gnu.org
@ 2011-10-11 12:34 ` burnus at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-10-11 12:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-10-11 12:33:26 UTC ---
Author: burnus
Date: Tue Oct 11 12:33:22 2011
New Revision: 179800

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179800
Log:
2011-10-11  Tobias Burnus  <burnus@net-b.de>

       PR fortran/50273
       * trans-common.c (translate_common): Fix -Walign-commons check.

2011-10-11  Tobias Burnus  <burnus@net-b.de>

       PR fortran/50273
       * gfortran.dg/common_16.f90: New.


Added:
    branches/gcc-4_5-branch/gcc/testsuite/gfortran.dg/common_16.f90
Modified:
    branches/gcc-4_5-branch/gcc/fortran/ChangeLog
    branches/gcc-4_5-branch/gcc/fortran/trans-common.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


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

end of thread, other threads:[~2011-10-11 12:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-02 10:03 [Bug fortran/50273] New: [4.5/4.6/4.7 Regression] -Walign-commons no longer effective burnus at gcc dot gnu.org
2011-09-02 10:11 ` [Bug fortran/50273] " rguenth at gcc dot gnu.org
2011-09-02 10:12 ` rguenth at gcc dot gnu.org
2011-09-02 12:57 ` burnus at gcc dot gnu.org
2011-09-07 17:12 ` jakub at gcc dot gnu.org
2011-10-10  6:54 ` burnus at gcc dot gnu.org
2011-10-11  9:59 ` burnus at gcc dot gnu.org
2011-10-11 12:34 ` burnus at gcc dot gnu.org
2011-10-11 12:34 ` burnus at gcc dot gnu.org

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