diff options
author | Harald Anlauf <anlauf@gmx.de> | 2022-08-20 20:36:28 +0200 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2022-08-22 20:40:12 +0200 |
commit | 7e51df048ae849115e12bf12702bdf1b65893be7 (patch) | |
tree | f463cc93368457f29f1c1e9f7c933526eb3c1964 /gcc/fortran/simplify.cc | |
parent | b6316324fceaef431799a8b386de5cc9881d6898 (diff) | |
download | gcc-7e51df048ae849115e12bf12702bdf1b65893be7.zip gcc-7e51df048ae849115e12bf12702bdf1b65893be7.tar.gz gcc-7e51df048ae849115e12bf12702bdf1b65893be7.tar.bz2 |
Fortran: fix simplification of intrinsics IBCLR and IBSET [PR106557]
gcc/fortran/ChangeLog:
PR fortran/106557
* simplify.cc (gfc_simplify_ibclr): Ensure consistent results of
the simplification by dropping a redundant memory representation
of argument x.
(gfc_simplify_ibset): Likewise.
gcc/testsuite/ChangeLog:
PR fortran/106557
* gfortran.dg/pr106557.f90: New test.
Diffstat (limited to 'gcc/fortran/simplify.cc')
-rw-r--r-- | gcc/fortran/simplify.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index fb72599..f992c31 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -3380,6 +3380,13 @@ gfc_simplify_ibclr (gfc_expr *x, gfc_expr *y) k = gfc_validate_kind (x->ts.type, x->ts.kind, false); result = gfc_copy_expr (x); + /* Drop any separate memory representation of x to avoid potential + inconsistencies in result. */ + if (result->representation.string) + { + free (result->representation.string); + result->representation.string = NULL; + } convert_mpz_to_unsigned (result->value.integer, gfc_integer_kinds[k].bit_size); @@ -3471,6 +3478,13 @@ gfc_simplify_ibset (gfc_expr *x, gfc_expr *y) k = gfc_validate_kind (x->ts.type, x->ts.kind, false); result = gfc_copy_expr (x); + /* Drop any separate memory representation of x to avoid potential + inconsistencies in result. */ + if (result->representation.string) + { + free (result->representation.string); + result->representation.string = NULL; + } convert_mpz_to_unsigned (result->value.integer, gfc_integer_kinds[k].bit_size); |