https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87669
Bug ID: 87669 Summary: Select type, incorrect handling of parameterized derived type Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: etdescdev at gmail dot com Target Milestone: --- The SELECT TYPE statement matches the class of a parameterized derived type without checking the kind parameter of the object. Tested on Ubuntu 18.10 (with gfortran 8.2.0-7ubuntu1 and 9.0.0 20181020 (r265341)) and macOS Mojave (with Homebrew GCC 8.2.0): Program Devtest Type dvtype(k) Integer, Kind :: k Real(k) :: a, b, c End Type dvtype type(dvtype(8)) :: dv dv%a = 1; dv%b = 2; dv%c = 3 call dvtype_print(dv) Contains Subroutine dvtype_print(p) class(*), intent(in) :: p Select Type(p) class is (dvtype(4)) print *, "dvtype4", p%k, p%a, p%b, p%c End Select Select Type(p) class is (dvtype(8)) print *, "dvtype8", p%k, p%a, p%b, p%c End Select End Subroutine dvtype_print End Output: dvtype4 8 0.00000000 0.00000000 1.87500000 dvtype8 8 1.0000000000000000 2.0000000000000000 3.0000000000000000 In this case, the compiler does not display any warning message with -Wall and -Wextra. This program compiles and runs without generating any error, yet it prints the line dvtype4 that does not correspond to the datatype of the object. In this statement, the kind parameter k is correctly evaluated, but the values a, b and c are displayed as if k were equal to 4.