GNU Fortran (GCC) 3.3.1 (cygming special) Compiled w/: g77 -fugly-logint -o cygt cyg_test.f - no errors, ./cygt Output: Test 1: If is true -2 Test 2: If is false 0 Compiled w/: g77 -o cygt cyg_test.f - no errors, ./cygt Output: Test 1: If is false F Test 2: If is false F Source of cyg_test.f: program cyg_test logical vis550 logical wkstub wkstub = .true. vis550 = .false. C C Note: These two if-then-else structures should produce the same C results. They should both be .false. C if (.not. (vis550 .or. wkstub)) then write (*,*) "Test 1: If is true", + .not. (vis550 .or. wkstub) else write (*,*) "Test 1: If is false", + .not. (vis550 .or. wkstub) endif if (.not. vis550 .and. .not. wkstub) then write (*,*) "Test 2: If is true", + .not. vis550 .and. .not. wkstub else write (*,*) "Test 2: If is false", + .not. vis550 .and. .not. wkstub endif end
I think this is related to: http://gcc.gnu.org/ml/gcc-patches/2002-05/msg00686.html
It looks like all logical expressions were broken by this patch (with the -fugly-logint option). IMHO, -fugly-logint should allow one to intermix logicals and integers in assignments but it should not change the meaning of the logical operators (.AND., .OR., etc.) <logical> .AND. <logical> should work the same without regard to the compiler option. Suggest that the patch be reverted. The problem mentioned in http://gcc.gnu.org/ml/gcc-patches/2002-05/msg00686.html could also be corrected by changing the LOGICAL declaration to INTEGER { for l4,ll4, and true } g77 -fugly-logint handles <integer> .AND. <integer> in exactly the way desired. regards, bud davis
Indeed, this is wrong. Will fix at least for 3.4
Subject: Bug 12633 CVSROOT: /cvs/gcc Module name: gcc Changes by: toon@gcc.gnu.org 2003-11-24 21:48:09 Modified files: gcc/f : ChangeLog expr.c Log message: 2003-11-24 Toon Moene <toon@moene.indiv.nluug.nl> PR fortran/12633 * expr.c (ffeexpr_reduced_ugly2log_): Revert change allowing logical .and. logical to be integer in expressions when -fugly-logint. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/f/ChangeLog.diff?cvsroot=gcc&r1=1.614&r2=1.615 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/f/expr.c.diff?cvsroot=gcc&r1=1.29&r2=1.30
Subject: Bug 12633 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: toon@gcc.gnu.org 2003-12-05 19:51:13 Modified files: gcc/f : ChangeLog expr.c Log message: 2003-12-05 Toon Moene <toon@moene.indiv.nluug.nl> PR fortran/12633 Revert 2002-05-09 Hassan Aurag <aurag@cae.com> * expr.c (ffeexpr_reduced_ugly2log_): Allow logicals-as-integers under -fugly-logint as arguments of .and., .or., .xor. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/f/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.503.2.33&r2=1.503.2.34 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/f/expr.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.25&r2=1.25.20.1
Fixed by reverting the solution to 6491.