This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, fortran] PR27996 and PR29978 - warnings and errors on character lengths
- From: Tobias Burnus <burnus at net-b dot de>
- To: Paul Thomas <paulthomas2 at wanadoo dot fr>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, Fortran List <fortran at gcc dot gnu dot org>
- Date: Fri, 22 Dec 2006 11:58:11 +0100
- Subject: Re: [Patch, fortran] PR27996 and PR29978 - warnings and errors on character lengths
- References: <456DE684.1030000@wanadoo.fr> <456EA501.4080907@net-b.de> <456F5705.8010406@wanadoo.fr>
Hi Paul,
Paul Thomas wrote:
>> elemental function specific__char_1_i16 (parm)
>> integer (kind=16) , intent (in) :: parm
>> character (kind=1,len=1) :: specific__char_1_i16
>> specific__char_1_i16 = char (parm, kind=1)
>> end function
>>
>> gfortran -c -Wall test.f90 # no error without -Wall
>> test.F90:0: internal compiler error: Segmentation fault
>>
> I missed this one in resubmittiing the patch a few minutes ago -
> ignore the resubmission, I'll fix this.
> I wonder why you seem to be more sensitive to segfaults than me? Is
> working on Cygwin protecting me sometimes?
Any news about this patch (30 November 2006)?
Latest patch was http://gcc.gnu.org/ml/gcc-patches/2006-11/msg02067.html
Valgrind outputs with your patch and my test case (-Wall):
==30070== Invalid read of size 8
==30070== at 0x44F86B: resolve_code (resolve.c:4975)
[...]
foo.f90:0: internal compiler error: Segmentation fault
Test case was:
elemental function specific__char_1_i16 (parm)
integer (kind=16) , intent (in) :: parm
character (kind=1,len=1) :: specific__char_1_i16
specific__char_1_i16 = char (parm, kind=1)
end function
The fix is to change
*************** resolve_code (gfc_code * code, gfc_names
+ else if (code->expr2->ts.cl->length
+ && code->expr2->ts.cl->length->expr_type == EXPR_CONSTANT)
into
+ else if (code->expr2->ts.cl
+ && code->expr2->ts.cl->length
+ && code->expr2->ts.cl->length->expr_type == EXPR_CONSTANT)
* * *
With regards to segmentation faults in general:
I often use the following of glibc's malloc options
# fill new malloc areas with 0x42
export MALLOC_PERTURB_=B
# Abort on any malloc related error.
export MALLOC_CHECK_=2
which are quite effective to find memory problems without affecting the
run-time speed too much. valgrind is, however, better suited to find the
exact spot of the problem.
Tobias