Bug 88649 - runtime error: load of value 137971008, which is not a valid value for type 'gfc_intrinsic_op'
Summary: runtime error: load of value 137971008, which is not a valid value for type '...
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Martin Liška
Depends on:
Blocks: ubsan
  Show dependency treegraph
Reported: 2019-01-02 07:38 UTC by Martin Liška
Modified: 2019-02-13 13:15 UTC (History)
0 users

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2019-01-02 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2019-01-02 07:38:07 UTC
Using ubsan GCC compiler, one can see:

$ ./xgcc -B. /home/marxin/Programming/gcc/gcc/testsuite/gfortran.dg/dec_bitwise_ops_1.f90 -O0 -fdec
../../gcc/fortran/resolve.c:4150:23: runtime error: load of value 137971008, which is not a valid value for type 'gfc_intrinsic_op'
    #0 0xb1362e in resolve_operator ../../gcc/fortran/resolve.c:4150
    #1 0xb2ffce in gfc_resolve_expr(gfc_expr*) ../../gcc/fortran/resolve.c:6825
    #2 0xb61cfa in gfc_resolve_code(gfc_code*, gfc_namespace*) ../../gcc/fortran/resolve.c:11269
    #3 0xb9cb84 in resolve_codes ../../gcc/fortran/resolve.c:16715
    #4 0xb9cd8b in gfc_resolve(gfc_namespace*) ../../gcc/fortran/resolve.c:16750
    #5 0xad072e in resolve_all_program_units ../../gcc/fortran/parse.c:6067
    #6 0xad1a20 in gfc_parse_file() ../../gcc/fortran/parse.c:6317
    #7 0xc3694a in gfc_be_parse_file ../../gcc/fortran/f95-lang.c:204
    #8 0x22fdf98 in compile_file ../../gcc/toplev.c:456
    #9 0x2305493 in do_compile ../../gcc/toplev.c:2176
    #10 0x2305ac1 in toplev::main(int, char**) ../../gcc/toplev.c:2311
    #11 0x466210c in main ../../gcc/main.c:39
    #12 0x7ffff608cfea in __libc_start_main ../csu/libc-start.c:308
    #13 0x872bd9 in _start (/home/marxin/Programming/gcc2/objdir/gcc/f951+0x872bd9)
Comment 1 Dominique d'Humieres 2019-01-02 12:15:42 UTC
I get

../../work/gcc/fortran/resolve.c:4151:23: runtime error: load of value 21200, which is not a valid value for type 'gfc_intrinsic_op'

with r267421, not no error with r259553.
Comment 2 Martin Liška 2019-01-25 12:08:10 UTC
Minimal test-case:

$ cat r.f90
a    = 3 .XOR. 5

$ ./xgcc -B. r.f90 -c -fdec
../../gcc/fortran/resolve.c:4148:23: runtime error: load of value 138343072, which is not a valid value for type 'gfc_intrinsic_op'
    #0 0xb1797f in resolve_operator ../../gcc/fortran/resolve.c:4148
    #1 0xb34835 in gfc_resolve_expr(gfc_expr*) ../../gcc/fortran/resolve.c:6847
    #2 0xb66561 in gfc_resolve_code(gfc_code*, gfc_namespace*) ../../gcc/fortran/resolve.c:11291
    #3 0xba15d8 in resolve_codes ../../gcc/fortran/resolve.c:16737
    #4 0xba17df in gfc_resolve(gfc_namespace*) ../../gcc/fortran/resolve.c:16772
    #5 0xad4ae4 in resolve_all_program_units ../../gcc/fortran/parse.c:6073
    #6 0xad5dd6 in gfc_parse_file() ../../gcc/fortran/parse.c:6323
    #7 0xc3b836 in gfc_be_parse_file ../../gcc/fortran/f95-lang.c:204
    #8 0x2309950 in compile_file ../../gcc/toplev.c:456
    #9 0x2310e4b in do_compile ../../gcc/toplev.c:2176
    #10 0x2311479 in toplev::main(int, char**) ../../gcc/toplev.c:2311
    #11 0x46926ce in main ../../gcc/main.c:39
    #12 0x7ffff608cfea in __libc_start_main ../csu/libc-start.c:308
    #13 0x875bd9 in _start (/home/marxin/Programming/gcc2/objdir/gcc/f951+0x875bd9)

Let me try to fix it.
Comment 3 Martin Liška 2019-01-25 12:27:37 UTC
I've got a patch candidate for it, am testing that.
Comment 4 Martin Liška 2019-02-13 13:05:27 UTC
Author: marxin
Date: Wed Feb 13 13:04:56 2019
New Revision: 268842

URL: https://gcc.gnu.org/viewcvs?rev=268842&root=gcc&view=rev
Fix -fdec simplification (PR fortran/88649).

2019-02-13  Martin Liska  <mliska@suse.cz>

	PR fortran/88649
	* resolve.c (resolve_operator): Initialize 't' right
	after function entry.  Skip switch (e->value.op.op)
	for -fdec operands that become function calls.

Comment 5 Martin Liška 2019-02-13 13:15:33 UTC
Fixed on trunk.