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

Re: patch reversion request

On Thursday, September 12, 2002, at 11:51 AM, Mark Mitchell wrote:

The attached patch breaks the following well formed C++,
	void baz (const long &)
	void foo (int a)
which is a regresion. see gnats prs 7828 & 7858
OK, I understand what's going on.  I see two ways to
fix it.  I'm writing to see if people have opinions about
which one is better.  (If you don't like either one, I
could probably come up with a third.)

What's happening is that we've got error checking in
build_unary_op to verify that the thing you're applying
& to is really an lvalue.  We certainly want to do that
error checking for user code.

The compiler is calling build_unary_op as part of the
pass-by-reference mechanism.  It checks to see if it
needs a temporary.  If not, it just calls build_unary_op.
The trouble is that the check to see whether or not it
needs a temporary isn't quite the same as the error-
checking in build_unary_op.  So convert_like_real
thinks that int and long are so similar that no temporary
is necessary, but build_unary_op disagrees.

OK, so here are my two options:
 1. Change the check in convert_like_real, so that a
cast like static_cast<long>(a)  is treated as something
that needs a temporary.  This is a trivial one-line change.
2. Add a parameter to build_unary_op telling it that it's
it's not dealing with user code and it doesn't need to
worry about error checking.  Conceptually easy, but
involves touching more lines of code.

I prefer option 1.  Opinions?

(Either way, of course, I'll also check in a new regression
test case.)


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