[Bug fortran/71544] gfortran compiler optimization bug when dealing with c-style pointers

2016-06-15 Thread noamb at bollweevil dot gdbg.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71544

--- Comment #4 from noamb  ---
(In reply to noamb from comment #3)

> However, presence of options that are invalid for
> 4.9.3 in that list makes me think that perhaps the correct list of options
> in that (moderately old) version is just different.

The same behavior (incorrect with -O1, correct with full list of specific
options) is also present on linux gfortran 4.9.3 when the list of options
turned on by -O1 is automatically generated by "-O1 -Q --help=optimizers":

tin 1035 : gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gnu/4.9.3/libexec/gcc/x86_64-unknown-linux-gnu/4.9.3/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/usr/local/gnu/4.9.3
--enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.9.3 (GCC) 

tin 1036 : gfortran -O1 orig_example.F90 ; ./a.out
 The following line should print 100
   589837704

tin 1037 : gfortran `gfortran -O1 -Q --help=optimizers | grep enabled | awk
'{print $1}'` orig_example.F90 ; ./a.out 
f951: warning: command line option ‘-frtti’ is valid for C++/ObjC++ but not for
Fortran
f951: warning: command line option ‘-fno-threadsafe-statics’ is valid for
C++/ObjC++ but not for Fortran
f951: warning: variable tracking requested, but useless unless producing debug
info
 The following line should print 100
 100

[Bug fortran/71544] gfortran compiler optimization bug when dealing with c-style pointers

2016-06-15 Thread noamb at bollweevil dot gdbg.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71544

--- Comment #3 from noamb  ---
(In reply to noamb from comment #2)

> I do not observe correct behavior with the options that the previous comment
> list s as being turned on by -O1 (this is on OS X 10.10, macports gfortran
> 4.9.3):

Sorry - this is wrong.  It was just failing to recompile because of the uknown
-fssa-* options.   Once I actually recompile with the long list of
optimizations documented as corresponding to -O1, it does work correctly, as
the first comment says.  However, presence of options that are invalid for
4.9.3 in that list makes me think that perhaps the correct list of options in
that (moderately old) version is just different.

[Bug fortran/71544] gfortran compiler optimization bug when dealing with c-style pointers

2016-06-15 Thread noamb at bollweevil dot gdbg.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71544

noamb  changed:

   What|Removed |Added

 CC||noamb at bollweevil dot 
gdbg.org

--- Comment #2 from noamb  ---
From Dominique d'Humieres
> Duplicate of pr71412?

This one is probably related, but does not actually involve calling a C
routine.  Also, that previous bug has different dependence on -O level (works
with -O0, fails with -O1, -O2, -O3, at least on OS X gfortran 4.9.3 from
macports)

I do not observe correct behavior with the options that the previous comment
list s as being turned on by -O1 (this is on OS X 10.10, macports gfortran
4.9.3):

[bernstei@rhodium tmp]$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin14/4.9.3/lto-wrapper
Target: x86_64-apple-darwin14
Configured with:
/opt/local/var/macports/build/_opt_mports_dports_lang_gcc49/gcc49/work/gcc-4.9.3/configure
--prefix=/opt/local --build=x86_64-apple-darwin14
--enable-languages=c,c++,objc,obj-c++,lto,fortran,java
--libdir=/opt/local/lib/gcc49 --includedir=/opt/local/include/gcc49
--infodir=/opt/local/share/info --mandir=/opt/local/share/man
--datarootdir=/opt/local/share/gcc-4.9 --with-local-prefix=/opt/local
--with-system-zlib --disable-nls --program-suffix=-mp-4.9
--with-gxx-include-dir=/opt/local/include/gcc49/c++/ --with-gmp=/opt/local
--with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local
--disable-isl-version-check --with-cloog=/opt/local
--disable-cloog-version-check --enable-stage1-checking --disable-multilib
--enable-lto --enable-libstdcxx-time --with-as=/opt/local/bin/as
--with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar
--with-bugurl=https://trac.macports.org/newticket --with-pkgversion='MacPorts
gcc49 4.9.3_0'
Thread model: posix
gcc version 4.9.3 (MacPorts gcc49 4.9.3_0) 

[bernstei@rhodium tmp]$ gfortran  -fauto-inc-dec -fbranch-count-reg
-fcombine-stack-adjustments -fcompare-elim -fcprop-registers -fdce -fdefer-pop
-fdse -fforward-propagate -fguess-branch-probability -fif-conversion2
-fif-conversion -finline-functions-called-once -fipa-pure-const -fipa-profile
-fipa-reference -fmerge-constants -fmove-loop-invariants -freorder-blocks
-fshrink-wrap -fsplit-wide-types -fssa-backprop -fssa-phiopt -ftree-bit-ccp
-ftree-ccp -ftree-ch -ftree-coalesce-vars -ftree-copy-prop -ftree-dce
-ftree-dominator-opts -ftree-dse -ftree-forwprop -ftree-fre -ftree-phiprop
-ftree-sink -ftree-slsr -ftree-sra -ftree-pta -ftree-ter -funit-at-a-time
-fomit-frame-pointer -fstrict-aliasing t.F90
gfortran: error: unrecognized command line option '-fssa-backprop'
gfortran: error: unrecognized command line option '-fssa-phiopt'

[bernstei@rhodium tmp]$ ./a.out 
 The following line should print 100
   0