This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, fortran, committed] Don't initialize mpfr data twice.


Hello,

gfc_get_constant_expr initializes the mpfr data, so there is no need to do so afterwards. This fixes for example some of the memory leaks present in the following testcase:

subroutine a
  integer :: i
  real    :: r
  complex :: c
  i = 0
  r = 0.0
  c = (0.0, 0.0)
end subroutine a

==33603== 16 bytes in 1 blocks are definitely lost in loss record 23 of 296
==33603== at 0x25A67B: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==33603== by 0x20F03B8: __gmp_default_allocate (in /usr/local/lib/libgmp.so.10)
==33603== by 0x1FBF6C5: mpfr_init2 (in /usr/local/lib/libmpfr.so.4)
==33603== by 0x4BB05D: gfc_get_constant_expr (expr.c:165)
==33603== by 0x51FD29: build_default_init_expr (resolve.c:9132)
==33603== by 0x5200E6: apply_default_init_local (resolve.c:9267)
==33603== by 0x5208C4: resolve_fl_variable (resolve.c:9480)
==33603== by 0x526554: resolve_symbol (resolve.c:11798)
==33603== by 0x54068C: traverse_ns (symbol.c:3332)
==33603== by 0x5406BB: traverse_ns (symbol.c:3335)
==33603== by 0x5406BB: traverse_ns (symbol.c:3335)
==33603== by 0x5406FA: gfc_traverse_ns (symbol.c:3348)



Committed as obvious at revision 162081


Mikael

Attachment: mpfr_init_twice.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]