public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/19168] New: Mismatched KINDs in SELECT CASE constucts is not handled correctly
@ 2004-12-27 17:40 sgk at troutmask dot apl dot washington dot edu
  2004-12-27 17:56 ` [Bug fortran/19168] " sgk at troutmask dot apl dot washington dot edu
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: sgk at troutmask dot apl dot washington dot edu @ 2004-12-27 17:40 UTC (permalink / raw)
  To: gcc-bugs

Consider this program posted by James Van Buskirk in c.l.f.
gfortran currently issues an error because the KIND of 7 and
200 do not match the KIND of x.

program case_ex
   implicit none
   integer, parameter :: ik1 = selected_int_kind(2)
   integer(ik1) x
   integer io

   write(*,'(a)',advance='no',iostat=io) ' Enter the value of x:> '
   read(*,*) x
   if(io /= 0) x = 0
   select case(x)
   case(7)
      write(*,'(a)') ' Sorry, bad guess.'
   case(200)
      write(*,'(a)') ' You win the prize!'
   case default
      write(*,'(a)') ' You aren''t even trying.'
   end select
end program case_ex

The relevant constraint from the Fortran standard is 

  C805 (R808) For a given case-construct, each case-value shall be of
  the same type as case-expr.  For character type, length differences
  are allowed, but the kind type parameters shall be the same.  */

and we note no such requirement of the KIND for INTEGER and LOGICAL
variables must match.

In the discussion on c.l.f, Richard Maine pointed out that the 
normal promotion rules for numeric rational operation should be
followed.

An initial patch was posted to http://gcc.gnu.org/ml/fortran/2004-12/msg00179.html
but it was deemed incorrect.

-- 
steve

-- 
           Summary: Mismatched KINDs in SELECT CASE constucts is not handled
                    correctly
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sgk at troutmask dot apl dot washington dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/19168] Mismatched KINDs in SELECT CASE constucts is not handled correctly
  2004-12-27 17:40 [Bug fortran/19168] New: Mismatched KINDs in SELECT CASE constucts is not handled correctly sgk at troutmask dot apl dot washington dot edu
@ 2004-12-27 17:56 ` sgk at troutmask dot apl dot washington dot edu
  2005-01-01 21:57 ` sgk at troutmask dot apl dot washington dot edu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: sgk at troutmask dot apl dot washington dot edu @ 2004-12-27 17:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sgk at troutmask dot apl dot washington dot edu  2004-12-27 17:56 -------
The relevant promoton rule is found in 7.2.3.

In the numeric relational operation
         x1 rel-op x2
if the types or kind type parameters of x1 and x2 differ, their values are
converted to the type and kind type parameter of the expression x1 + x2
before evaluation.

In the CASE SELECT situation, rel-op is .EQ. (or ==).

-- 
steve

-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/19168] Mismatched KINDs in SELECT CASE constucts is not handled correctly
  2004-12-27 17:40 [Bug fortran/19168] New: Mismatched KINDs in SELECT CASE constucts is not handled correctly sgk at troutmask dot apl dot washington dot edu
  2004-12-27 17:56 ` [Bug fortran/19168] " sgk at troutmask dot apl dot washington dot edu
@ 2005-01-01 21:57 ` sgk at troutmask dot apl dot washington dot edu
  2005-01-09  4:55 ` giovannibajo at libero dot it
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: sgk at troutmask dot apl dot washington dot edu @ 2005-01-01 21:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sgk at troutmask dot apl dot washington dot edu  2005-01-01 21:57 -------
There is a patch at http://gcc.gnu.org/ml/gcc-patches/2005-01/msg00023.html

-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/19168] Mismatched KINDs in SELECT CASE constucts is not handled correctly
  2004-12-27 17:40 [Bug fortran/19168] New: Mismatched KINDs in SELECT CASE constucts is not handled correctly sgk at troutmask dot apl dot washington dot edu
  2004-12-27 17:56 ` [Bug fortran/19168] " sgk at troutmask dot apl dot washington dot edu
  2005-01-01 21:57 ` sgk at troutmask dot apl dot washington dot edu
@ 2005-01-09  4:55 ` giovannibajo at libero dot it
  2005-01-16 12:51 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: giovannibajo at libero dot it @ 2005-01-09  4:55 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/19168] Mismatched KINDs in SELECT CASE constucts is not handled correctly
  2004-12-27 17:40 [Bug fortran/19168] New: Mismatched KINDs in SELECT CASE constucts is not handled correctly sgk at troutmask dot apl dot washington dot edu
                   ` (2 preceding siblings ...)
  2005-01-09  4:55 ` giovannibajo at libero dot it
@ 2005-01-16 12:51 ` cvs-commit at gcc dot gnu dot org
  2005-01-16 13:04 ` pbrook at gcc dot gnu dot org
  2005-01-16 16:04 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-01-16 12:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-01-16 12:51 -------
Subject: Bug 19168

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pbrook@gcc.gnu.org	2005-01-16 12:51:04

Modified files:
	gcc/fortran    : ChangeLog resolve.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: select_5.f90 

Log message:
	2005-01-16  Steven G. Kargl  <kargls@comcast.net>
	
	PR 19168
	* resolve.c (check_case_overlap): Typo in comment.
	(validate_case_label_expr):  Fix up kinds of case values
	(resolve_select): Properly handle kind mismatches.
	testsuite/
	* gfortran.dg/select_5.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.294&r2=1.295
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/resolve.c.diff?cvsroot=gcc&r1=1.27&r2=1.28
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4894&r2=1.4895
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/select_5.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/19168] Mismatched KINDs in SELECT CASE constucts is not handled correctly
  2004-12-27 17:40 [Bug fortran/19168] New: Mismatched KINDs in SELECT CASE constucts is not handled correctly sgk at troutmask dot apl dot washington dot edu
                   ` (3 preceding siblings ...)
  2005-01-16 12:51 ` cvs-commit at gcc dot gnu dot org
@ 2005-01-16 13:04 ` pbrook at gcc dot gnu dot org
  2005-01-16 16:04 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: pbrook at gcc dot gnu dot org @ 2005-01-16 13:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pbrook at gcc dot gnu dot org  2005-01-16 13:04 -------
Fixed. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/19168] Mismatched KINDs in SELECT CASE constucts is not handled correctly
  2004-12-27 17:40 [Bug fortran/19168] New: Mismatched KINDs in SELECT CASE constucts is not handled correctly sgk at troutmask dot apl dot washington dot edu
                   ` (4 preceding siblings ...)
  2005-01-16 13:04 ` pbrook at gcc dot gnu dot org
@ 2005-01-16 16:04 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-16 16:04 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.0


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/19168] Mismatched KINDs in SELECT CASE constucts is not handled correctly
       [not found] <bug-19168-8446@http.gcc.gnu.org/bugzilla/>
@ 2010-05-10 11:51 ` burnus at gcc dot gnu dot org
  0 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-05-10 11:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2010-05-10 11:51 -------
James Van Buskirk post:
 
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/7681f2c8f86c4687/


-- 


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-05-10 11:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-27 17:40 [Bug fortran/19168] New: Mismatched KINDs in SELECT CASE constucts is not handled correctly sgk at troutmask dot apl dot washington dot edu
2004-12-27 17:56 ` [Bug fortran/19168] " sgk at troutmask dot apl dot washington dot edu
2005-01-01 21:57 ` sgk at troutmask dot apl dot washington dot edu
2005-01-09  4:55 ` giovannibajo at libero dot it
2005-01-16 12:51 ` cvs-commit at gcc dot gnu dot org
2005-01-16 13:04 ` pbrook at gcc dot gnu dot org
2005-01-16 16:04 ` pinskia at gcc dot gnu dot org
     [not found] <bug-19168-8446@http.gcc.gnu.org/bugzilla/>
2010-05-10 11:51 ` burnus at gcc dot gnu dot org

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).