Bug 12633 - [g77 3.3/3.4 regression] logical expression gives incorrect result with -fugly-logint option
Summary: [g77 3.3/3.4 regression] logical expression gives incorrect result with -fugl...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 3.3.3
: P2 normal
Target Milestone: 3.3.3
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-16 07:06 UTC by Doug Wyatt
Modified: 2004-01-17 04:22 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-11-15 12:46:53


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Doug Wyatt 2003-10-16 07:06:52 UTC
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
Comment 1 bdavis9659 2003-10-19 19:04:00 UTC
I think this is related to:

http://gcc.gnu.org/ml/gcc-patches/2002-05/msg00686.html

 


 

            
Comment 2 bdavis9659 2003-10-28 02:56:10 UTC
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
Comment 3 Toon Moene 2003-11-15 12:46:53 UTC
Indeed, this is wrong.  Will fix at least for 3.4
Comment 4 CVS Commits 2003-11-24 21:48:13 UTC
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

Comment 5 CVS Commits 2003-12-05 19:51:19 UTC
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

Comment 6 Toon Moene 2003-12-05 19:57:02 UTC
Fixed by reverting the solution to 6491.