------- Comment #5 from dfranke at gcc dot gnu dot org 2010-05-09 09:11 ------- (In reply to comment #4) > It should be sufficient to convert all case-selectors to the same kind as the > case-expression. We should then be giving exactly the same error as g95, > unless I'm missing something.
This is directly contradicting the conclusion reached in PR19168 where it was decided that the case-expr should be promoted to the largest kind of the case-values (short summary: case values shall be of the same type, but only character expressions are required to be of same kind, hence apply the same conversion rules as for direct comparison; see F2003, C805 (R808); F2008, C832 (R838)). In the example below, the comparison done for the IF statement is promoted to default integer kind (see dump), no warning is generated for the unreachable branch. Same holds for the equivalent SELECT. INTEGER(KIND=1) i i = 100 IF (i == 200) THEN print *, "unreachable!" ELSE print *, "default!" END IF SELECT CASE (i) CASE (200) print *, "unreachable!" CASE DEFAULT print *, "default!" END SELECT END Nonetheless, I also think that it is counter-intuitive. The least that could be done: add a warning (-Wconversion? -Wsurprising?) before converting the case-expr, mentioning that at least one case-value has a kind larger than the case-expressions kind, which thus can not be reached. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31820