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]

Re: Address of a cast expression in C++


On Thursday, July 25, 2002, at 11:38 AM, Gabriel Dos Reis wrote:

| As I read the C++ Standard, this is incorrect; a diagnostic is
| required.  5.4/1 says that the result of (char)n is an rvalue,
| and 5.3.1/2 says that you can't take the address of an rvalue.
|
| Question: is this violation of the C++ Standard deliberate,
| or is it a bug?

I would say it is a result of a bug -- I suspect another instance of
code duplication where the problem is fixed in C but not in C++ :-(
You're right that code duplication is evil, but the problem here
turns out to be different from what we thought.  The logic in
build_unary_op is the same in the C and C++ front ends.
Unfortunately, both front ends call the same function, one in
gcc/tree.c and the other in gcc/cp/tree.c, and the functions have
just slightly different semantics.

I've submitted a patch.

			--Matt


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