Bug 61907 - load of invalid value for 'bool' in trans-array.c trans_array_constructor
Summary: load of invalid value for 'bool' in trans-array.c trans_array_constructor
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 7.0
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: ubsan
  Show dependency treegraph
 
Reported: 2014-07-25 09:24 UTC by Vittorio Zecca
Modified: 2018-04-02 09:38 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-09-04 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vittorio Zecca 2014-07-25 09:24:03 UTC
Compiling many testsuite files with a sanitized gfortran,
as in typebound_assignment_6.f03, elemental_subroutine_2.f90, move_alloc_13.f90, where_operator_assign_2.f90, pr43808.f90, and more, I get the following
"../../gcc-4.9.1/gcc/fortran/trans-array.c:2207:9: runtime error: 
load of value xxx, which is not a valid value for type 'bool'"
The offending instructions are
2206:"  typespec_chararray_ctor = (expr->ts.u.cl
2207:                             && expr->ts.u.cl->length_from_typespec);" 
in trans_array_constructor.
Comment 1 Marek Polacek 2014-09-04 09:51:05 UTC
$ ./xgcc -B./ -c typebound_assignment_6.f03 
/home/polacek/src/gcc/gcc/fortran/trans-array.c:2211:9: runtime error: load of value 176, which is not a valid value for type 'bool'
/home/polacek/src/gcc/gcc/fortran/trans-expr.c:5280:27: runtime error: member call on null pointer of type 'struct vec'
/home/polacek/src/gcc/gcc/fortran/trans-expr.c:5283:32: runtime error: member call on null pointer of type 'struct vec'
/home/polacek/src/gcc/gcc/fortran/trans-expr.c:5286:30: runtime error: member call on null pointer of type 'struct vec'

Confirmed.
Comment 2 Jakub Jelinek 2014-10-30 10:40:20 UTC
GCC 4.9.2 has been released.
Comment 3 Vittorio Zecca 2015-04-24 15:53:35 UTC
Same behaviour in 4.9.2 in trans-array.c line 2206

typespec_chararray_ctor = (expr->ts.u.cl && expr->ts.u.cl->length_from_typespec);

It seems length_from_typespec is wrong,
OR the sanitizer -fsanitize=undefined is wrong.

Trying the following:
! taken from pr43808.f90
  type :: a
    integer, allocatable :: i(:)
  end type a
  type :: b
    type (a), allocatable :: j(:)
  end type b
  type(a) :: x(1)
  type(b) :: y(1)
  y(1) = b((/x(1)/))
end

I get 
/home/vitti/gcc-4.9.2-sanitize/test/f951 p.f90
 MAIN__../../gcc-4.9.2/gcc/fortran/trans-array.c:2206:44: runtime error: load of value 172, which is not a valid value for type 'bool'
 main
Analyzing compilation unit
Performing interprocedural optimizations
 <*free_lang_data> <visibility> <early_local_cleanups> <*free_inline_summary> <whole-program> <inline>Assembling functions:
 MAIN__ main
Comment 4 Vittorio Zecca 2015-04-25 10:38:54 UTC
Still in 5.1.0 at trans-array.c:2223
Comment 5 Jakub Jelinek 2015-06-26 19:57:40 UTC
GCC 4.9.3 has been released.
Comment 6 Vittorio Zecca 2016-08-11 13:28:56 UTC
Still there in gcc 7.0 trunk 239276
Comment 7 Martin Liška 2018-03-01 11:48:30 UTC
Also can't reproduce on current trunk, is it still valid?
Comment 8 Vittorio Zecca 2018-04-02 09:38:17 UTC
Sanitizer warning was there in 6.4.0 but disappeared in version 7.