https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78290
Harald Anlauf <anlauf at gmx dot de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gmx dot de --- Comment #2 from Harald Anlauf <anlauf at gmx dot de> --- While trying to reduce the reproducer, I encountered a situation where adding a VOLATILE statement triggers an ICE for the code that is miscompiled: pr78290a.f90:18:0: ip=>ia internal compiler error: in gfc_add_modify_loc, at fortran/trans.c:159 0x835756e gfc_add_modify_loc(unsigned int, stmtblock_t*, tree_node*, tree_node*) ../../trunk/gcc/fortran/trans.c:158 0x83575e7 gfc_add_modify(stmtblock_t*, tree_node*, tree_node*) ../../trunk/gcc/fortran/trans.c:170 0x83a90eb gfc_trans_pointer_assignment(gfc_expr*, gfc_expr*) ../../trunk/gcc/fortran/trans-expr.c:8267 0x83a9688 gfc_trans_pointer_assign(gfc_code*) ../../trunk/gcc/fortran/trans-expr.c:8054 0x8358357 trans_code ../../trunk/gcc/fortran/trans.c:1714 0x838d62c gfc_generate_function_code(gfc_namespace*) ../../trunk/gcc/fortran/trans-decl.c:6261 0x830d833 translate_all_program_units ../../trunk/gcc/fortran/parse.c:6038 0x830d833 gfc_parse_file() ../../trunk/gcc/fortran/parse.c:6238 0x8352db5 gfc_be_parse_file ../../trunk/gcc/fortran/f95-lang.c:202 % cat pr78290a.f90 ! Wrong code PROGRAM main IMPLICIT NONE INTEGER,PARAMETER::KI=4 TYPE mytype INTEGER(KIND=KI)::i=1_KI END TYPE mytype TYPE(mytype), DIMENSION(9),TARGET, SAVE::ta INTEGER(KIND=KI),DIMENSION(3),TARGET, SAVE::ia = 3_KI INTEGER(KIND=KI),DIMENSION(:),POINTER ::ia2 =>NULL() INTEGER(KIND=KI),DIMENSION(:),POINTER ::ip =>NULL() volatile::ip ALLOCATE(ia2(5)); ia2=2_KI ip=>ia print*,size(ip) CALL sub1(ip) print*,size(ip) WRITE(*,*)'ia ',ia WRITE(*,*)'ip ',ip ip=>ta%i !!! Works if you comment this line out !!! ! Produces: ! ia 2 2 2 ! ip 2 2 2 ! ! Should produce: ! ia 3 3 3 ! ip 2 2 2 2 2 ! ! Seems to be creating a copy of ia and setting argument ipa as a pointer this, and ! changes to this never get transferred back to ia ! Also does not transfer back change of target or INOUT argugment ! Works if you comment out the line "ip=>ta%i" ! CONTAINS SUBROUTINE sub1(ipa) INTEGER(KIND=KI),DIMENSION(:),POINTER::ipa ipa => ia2 END SUBROUTINE sub1 END PROGRAM main