public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mark_l_hansen at yahoo dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/21931] New: problem with fugly-logint flag and evaluating if statements
Date: Mon, 06 Jun 2005 15:48:00 -0000	[thread overview]
Message-ID: <20050606154812.21931.mark_l_hansen@yahoo.com> (raw)

The -fugly-logint flag allows FORTRAN to treat integers as logicals and vice 
versa.  The following example program shows some inconsistencies in how the if 
statements evaluate.  If you change VAR1 to 3,2,1,0,-1 and view the results you 
will see some interesting things.  The best way to see the problem is to view 
the output.  Thanks.  I would appreciate an email if anyone has a solution/fix 
for the problem.  Thanks.

Below is the code----

Makefile:
all:
	g77 -c -g -ff90 -ff90-intrinsics-delete -fugly-logint -fno-automatic 
function.for
	g++ -c -g main.cpp
	g++  -o program main.o function.o -lg2c 

main.cpp:
        #include <iostream>
        #include <vector>
        using namespace std;

        extern "C" {
	        void func_();
        }

        int main()
        {
	        func_();
        	return 0;
        }
function.for:
      SUBROUTINE FUNC
      
      IMPLICIT NONE
*
*  LOCAL DECLARATIONS
*
      INTEGER VAR1, VAR2

      LOGICAL LVAR1, LVAR2, LOG1, LOG2

      EQUIVALENCE
     .  (VAR1, LVAR1)
     ., (VAR2, LVAR2)

*C change VAR1 to 2,-1,0,3 and view results     
      VAR1 =  3;
      VAR2 =  -1;
      LOG1 = .true.
      LOG2 = .true.
      
      WRITE (*,*) "LOG1  = ", LOG1
      WRITE (*,*) "LOG2  = ", LOG2
      WRITE (*,*) "VAR1  = ", VAR1
      WRITE (*,*) "VAR2  = ", VAR2
      WRITE (*,*) "LVAR1 = ", LVAR1
      WRITE (*,*) "LVAR2 = ", LVAR2

      IF(.NOT.((LVAR1 .AND. LVAR2) .AND. (LOG1 .AND. LOG2))) THEN
        WRITE (*,*) "LOGICAL TRUE with LOG2"         
      ELSE
        WRITE (*,*) "LOGICAL FALSE with LOG2"         
      ENDIF
      IF(.NOT.(LVAR1 .AND. LVAR2 .AND. LOG1)) THEN
        WRITE (*,*) "LOGICAL TRUE with LOG1"         
      ELSE
        WRITE (*,*) "LOGICAL FALSE with LOG1"         
      ENDIF
      IF(.NOT.(LVAR1 .AND. LVAR2)) THEN
        WRITE (*,*) "LOGICAL TRUE"         
      ELSE
        WRITE (*,*) "LOGICAL FALSE"         
      ENDIF
*----------------------------------------------------------------------      
      IF(.NOT.(VAR1 .AND. VAR2 .AND. LOG1)) THEN
        WRITE (*,*) "BYTE TRUE with LOG1"         
      ELSE
        WRITE (*,*) "BYTE FALSE with LOG1"         
      ENDIF
      IF(.NOT.(VAR1 .AND. VAR2)) THEN
        WRITE (*,*) "BYTE TRUE"         
      ELSE
        WRITE (*,*) "BYTE FALSE"         
      ENDIF
     
      END

-- 
           Summary: problem with fugly-logint flag and evaluating if
                    statements
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mark_l_hansen at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


             reply	other threads:[~2005-06-06 15:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-06 15:48 mark_l_hansen at yahoo dot com [this message]
2005-06-06 15:51 ` [Bug fortran/21931] " mark_l_hansen at yahoo dot com
2005-06-10 14:53 ` bdavis9659 at comcast dot net
2005-06-18 18:48 ` fxcoudert at gcc dot gnu dot org
2005-06-19 18:39 ` mark_l_hansen at yahoo dot com
2005-06-25 13:58 ` bdavis9659 at comcast dot net
2005-06-25 14:06 ` bdavis9659 at comcast dot net
2005-06-29  2:08 ` mark_l_hansen at yahoo dot com
2005-09-09 14:36 ` bdavis9659 at comcast dot net
2005-09-09 14:38 ` bdavis9659 at comcast dot net

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050606154812.21931.mark_l_hansen@yahoo.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).