tag 210848 + patch thanks Hello,
Here is a .dpatch file based on the patch posted on [EMAIL PROTECTED] [1]. I built gcc with this patch, and I tried to run the testcase. I confirm that it fixes the bug. Cheers, Aurelien [1] http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00853.html
#! /bin/sh -e # DP: Unsharing lhs (leading to generate an infinite loop with inline # DP: functions). if [ $# -eq 3 -a "$2" = '-d' ]; then pdir="-d $3" elif [ $# -ne 1 ]; then echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" exit 1 fi case "$1" in -patch) patch $pdir -f --no-backup-if-mismatch -p0 < $0 ;; -unpatch) patch $pdir -f --no-backup-if-mismatch -R -p0 < $0 ;; *) echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" exit 1 esac exit 0 --- gcc/cp/typeck.c 2003-09-19 15:53:40 +0200 +++ gcc/cp/typeck.c 2003-09-19 15:53:58 +0200 @@ -5526,9 +5526,18 @@ { tree result_type = TREE_TYPE (newrhs); + tree lhs2; + + /* Ensure that the calls are not shared with the lhs kept + at condition. */ + if (TREE_SIDE_EFFECTS (lhs)) + lhs2 = break_out_calls (lhs); + else + lhs2 = lhs; + /* We have to convert each arm to the proper type because the types may have been munged by constant folding. */ result = build (COND_EXPR, result_type, cond, - build_modify_expr (lhs, modifycode, + build_modify_expr (lhs2, modifycode, cp_convert (result_type, TREE_OPERAND (newrhs, 1))),