This is the mail archive of the gcc@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]

A bug in the current released GCC 4.0.0


Hello,

I casually found a bug in the current released GCC 4.0.0.  However, I
have located the wrong code, and it's very easy to be fixed, so it's not
necessary to still submit a bug report.  See the following artificial
C++ code:

	int *x;
	void f()
	{
		do
		{
			const int *&rx = (const int*&)(x);
			rx = 0;
		}while( *x );
	}

Compile it with command "cc1plus -O2" will cause an internal error
happening in get_indirectref_operands, at tree-ssa-operands.c:1449,
which is because GCC gets into the unreachable branch.  The underlying
fault is in create_expression_by_pieces, at tree-ssa-pre.c:1382.

	if (!is_gimple_min_invariant (genop1))
	  newexpr = force_gimple_operand (folded, &forced_stmts, false,
NULL);
	else
1382:	  newexpr = genop1;

I guess it's a clerical error.  The genop1 is just a GIMPLE
min_invariant operand of the expression being processed.  What holds the
needed expression here is the variable FOLDED, so this line should be as
following.

1382:	  newexpr = folded;

I modified it as so and it works correctly when compiling the above
artificial code and also my project files on which the unmodified
version fails.

I hope this is helpful to the maintainers.


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