Bug 30881 - Select case of case(transfer(...)) wrongly rejected
Summary: Select case of case(transfer(...)) wrongly rejected
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Brooks Moses
URL:
Keywords: ice-on-valid-code, rejects-valid
Depends on: 18769
Blocks: 31237 31216
  Show dependency treegraph
 
Reported: 2007-02-20 07:53 UTC by Joost VandeVondele
Modified: 2007-05-26 03:08 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.3.0 4.2.0 4.1.2
Last reconfirmed: 2007-04-06 22:56:55


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2007-02-20 07:53:34 UTC
With recent trunk, gfortran incorrectly generates an error for the following standard code:
INTEGER, PARAMETER :: K=1
INTEGER ::  I
I=TRANSFER(.TRUE.,K)
SELECT CASE(I)
CASE(TRANSFER(.TRUE.,K))
CASE(TRANSFER(.FALSE.,K))
 CALL ABORT()
CASE DEFAULT
 CALL ABORT()
END SELECT
I=TRANSFER(.FALSE.,K)
SELECT CASE(I)
CASE(TRANSFER(.TRUE.,K))
 CALL ABORT()
CASE(TRANSFER(.FALSE.,K))
CASE DEFAULT
 CALL ABORT()
END SELECT
END
Comment 1 Dominique d'Humieres 2007-02-20 10:57:32 UTC
With Target: powerpc-apple-darwin7, gcc version 4.3.0 20070216, 
plus patch for PR #30400, I have:

[address=437ffffc pc=42343560]
pr30881.f90:0: internal compiler error: Segmentation Fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 2 Tobias Burnus 2007-02-20 13:23:53 UTC
I cannot reproduce the ICE with 4.3.0 20070220/x86_64-unknown-linux-gnu. I get the following error:

CASE(TRANSFER(.TRUE.,K))
    1
foo.f90:6.5:
CASE(TRANSFER(.FALSE.,K))
    2
Error: CASE label at (1) overlaps with CASE label at (2)

The file compiles correctly with NAGf95, g95 and ifort. (However, ifort calls wrongly the second abort.)
Comment 3 Francois-Xavier Coudert 2007-03-03 12:36:28 UTC
I also get the ICE on i686-linux. We get into compare_cases (resolve.c) and try to compare op1->high and op2->low, but both are functions and not constants, so the values in op1->high->value are meaningless, and comparing them yields random segfaults.

If we get it past that point, we later ICE in gfc_conv_constant_to_tree, at fortran/trans-const.c:278 (because the expr is not an EXPR_CONSTANT). This will all be fixed when the simplifcation routine for TRANSFER is written.
Comment 4 Paul Thomas 2007-03-07 10:53:28 UTC
(In reply to comment #3)

> fortran/trans-const.c:278 (because the expr is not an EXPR_CONSTANT). This will
> all be fixed when the simplifcation routine for TRANSFER is written.

FX, You are correct - this is effectively PR18769.

Paul
Comment 5 Paul Thomas 2007-05-16 06:41:25 UTC
Subject: Bug 30881

Author: pault
Date: Wed May 16 05:40:51 2007
New Revision: 124759

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124759
Log:
2007-05-16  Brooks Moses  <brooks.moses@codesourcery.com>

	PR fortran/18769
	PR fortran/30881
	PR fortran/31194
	PR fortran/31216
	PR fortran/31427
	* target-memory.c: New file.
	* target-memory.h: New file.
	* simplify.c: Add #include "target-memory.h".
	(gfc_simplify_transfer): Implement constant-
	folding for TRANSFER intrinsic.
	* Make-lang.in: Add dependencies on new target-memory.* files.

2007-05-16  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/18769
	PR fortran/30881
	PR fortran/31194
	PR fortran/31216
	PR fortran/31427
	* transfer_simplify_1.f90: New test.
	* transfer_simplify_2.f90: New test.

Added:
    trunk/gcc/fortran/target-memory.c
    trunk/gcc/fortran/target-memory.h
    trunk/gcc/testsuite/gfortran.dg/transfer_simplify_1.f90
    trunk/gcc/testsuite/gfortran.dg/transfer_simplify_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/Make-lang.in
    trunk/gcc/fortran/simplify.c
    trunk/gcc/testsuite/ChangeLog

Comment 6 Paul Thomas 2007-05-16 09:11:47 UTC
Fixed on trunk

Paul and Brooks