[Bug fortran/91359] logical function X returns .TRUE. - Warning: spaghetti code

2019-08-12 Thread briantcarcich at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91359

--- Comment #18 from Brian T. Carcich  ---
Thanks for the fix and your patience.

We got gfortran with this patch to build on a box running Linux 2.6.9 ca.
November 2011, and it solved the problem.

Well done.

[Bug fortran/91359] logical function X returns .TRUE. - Warning: spaghetti code

2019-08-07 Thread briantcarcich at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91359

--- Comment #13 from Brian T. Carcich  ---
Whoops, I meant rev 274149.

[Bug fortran/91359] logical function X returns .TRUE. - Warning: spaghetti code

2019-08-07 Thread briantcarcich at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91359

--- Comment #12 from Brian T. Carcich  ---
Steve,

I ran GCC SVN repo rev 274151 against part of our SFTRAN3-generated codebase,
and they now pass the unit tests.

This work will be used to update the MIRAGE suite of software for
high-precision trajectory determination of active spacecraft missions (New
Horizons, OSIRIS-REx, etc.).

Thank you for your efforts, despite your better judgement.  Again, I apologize
for my carelessness in reading what you initially wrote and the arrogance and
stupidity in my response.

Best regards,

Brian T. Carcich

[Bug fortran/91359] logical function X returns .TRUE. - Warning: spaghetti code

2019-08-06 Thread briantcarcich at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91359

--- Comment #10 from Brian T. Carcich  ---
thank you.

On Tue, Aug 6, 2019 at 2:28 PM kargl at gcc dot gnu.org <
gcc-bugzi...@gcc.gnu.org> wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91359
>
> --- Comment #9 from kargl at gcc dot gnu.org ---
> Against my better judgement, I have submitted a patch that seems to fix
> this
> issue.
>
> --
> You are receiving this mail because:
> You reported the bug.

[Bug fortran/91359] logical function X returns .TRUE. - Warning: spaghetti code

2019-08-05 Thread briantcarcich at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91359

--- Comment #8 from Brian T. Carcich  ---
Not exactly a page out of Dale Carnegie.

[Bug fortran/91359] logical function X returns .TRUE. - Warning: spaghetti code

2019-08-05 Thread briantcarcich at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91359

--- Comment #7 from Brian T. Carcich  ---
Oh dear.

[Bug fortran/91359] logical function X returns .TRUE. - Warning: spaghetti code

2019-08-05 Thread briantcarcich at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91359

--- Comment #5 from Brian T. Carcich  ---
S ... as does yours, probably

--- Comment #6 from Brian T. Carcich  ---
S ... as does yours, possibly.

[Bug fortran/91359] logical function X returns .TRUE. - Warning: spaghetti code

2019-08-05 Thread briantcarcich at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91359

--- Comment #5 from Brian T. Carcich  ---
S ... as does yours, probably

--- Comment #6 from Brian T. Carcich  ---
S ... as does yours, possibly.

[Bug fortran/91359] logical function X returns .TRUE. - Warning: spaghetti code

2019-08-05 Thread briantcarcich at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91359

--- Comment #4 from Brian T. Carcich  ---
PPPS I apologize; by way of ignorant excuse, my history with Fortran goes back
way more than 29y.

[Bug fortran/91359] logical function X returns .TRUE. - Warning: spaghetti code

2019-08-05 Thread briantcarcich at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91359

--- Comment #2 from Brian T. Carcich  ---
Agreed that the options -finit-local-zero and -fno-automatic are extraneous;
sorry, they were dragged into here from my Makefile because I need them for the
larger project.

Also, I know how to do a workaround, several in fact, to trick GFORTRAN into
doing the correct thing, as demonstrated by the Github example; that is not the
issue.

The issue is that this *is* a bug in GFORTRAN:  the return on Line 3 (label
2) should cause GFORTRAN to generate a correct [return __result_zero;], and
not the incorrect naked [return;] that it does now.

Other FORTRAN compilers do that, also earlier version of GFORTRAN, because it
is correct.

If I get some free time I will work on a patch, but I suspect someone familiar
with the code could fix this before I suss out where the fix should be done.

Thanks,

Brian Carcich

[Bug fortran/91359] New: GFORTRAN [NNNNN RETURN] of .FALSE. logical function X returns .TRUE. after [if (.not.X) goto NNNNN] - Warning: spaghetti code

2019-08-05 Thread briantcarcich at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91359

Bug ID: 91359
   Summary: GFORTRAN [N RETURN]  of .FALSE. logical function X
returns .TRUE. after [if (.not.X) goto N] -
Warning:  spaghetti code
   Product: gcc
   Version: 5.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: briantcarcich at gmail dot com
  Target Milestone: ---

Created attachment 46673
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46673=edit
Minimal test case; test_zero.f90 from gfortran -save-temps ... test_zero.f

This error does not appear with G77; I also tried it with GFORTRAN 4.4.7 and it
did not appear there. 

I attached a minimal test case (.f90, not .i*, as this is FORTRAN).  It was
generated from source file test_zero.f, which has the following contents:

  logical function zero()
  goto 2
1 return
2 zero = .false.
  if (.not.zero) goto 1
  return
  end
  program test_zero
  logical zero
  if (zero()) stop 'FAIL:  zero() returned .TRUE.'
  stop 'OKAY:  zero() returned .FALSE.'
  end

The simplest commands to produce the bug are preceded by [>] below; the
responses are as shown between the commands:

> gfortran -std=legacy -g -O0 -finit-local-zero -fno-automatic -Wall \
  test_zero.f  -o test_zero_gfortran.e -save-temps -v

Driving: gfortran -std=legacy -g -O0 -finit-local-zero -fno-automatic -Wall
test_zero.f -o test_zero_gfortran.e -save-temps -v -l gfortran -l m
-shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
5.4.0-6ubuntu1~16.04.11' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11) 
COLLECT_GCC_OPTIONS='-std=legacy' '-g' '-O0' '-finit-local-zero'
'-fno-automatic' '-Wall' '-o' 'test_zero_gfortran.e' '-save-temps' '-v'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/5/f951 test_zero.f -ffixed-form -quiet -dumpbase
test_zero.f -mtune=generic -march=x86-64 -auxbase test_zero -g -O0 -Wall
-std=legacy -version -finit-local-zero -fno-automatic -fintrinsic-modules-path
/usr/lib/gcc/x86_64-linux-gnu/5/finclude -o test_zero.s
GNU Fortran (Ubuntu 5.4.0-6ubuntu1~16.04.11) version 5.4.0 20160609
(x86_64-linux-gnu)
compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR
version 3.1.4, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (Ubuntu 5.4.0-6ubuntu1~16.04.11) version 5.4.0 20160609
(x86_64-linux-gnu)
compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR
version 3.1.4, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
test_zero.f:3:0:

 1 return
 ^
Warning: control reaches end of non-void function [-Wreturn-type]
COLLECT_GCC_OPTIONS='-std=legacy' '-g' '-O0' '-finit-local-zero'
'-fno-automatic' '-Wall' '-o' 'test_zero_gfortran.e' '-save-temps' '-v'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 as -v --64 -o test_zero.o test_zero.s
GNU assembler version 2.26.1 (x86_64-linux-gnu) using BFD version (GNU Binutils
for Ubuntu) 2.26.1
Reading specs from /usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-std=legacy' '-g' '-O0' '-finit-local-zero'
'-fno-automatic' '-Wall' '-o' 'test_zero_gfortran.e' '-save-temps' '-v'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-