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: generalized lvalues -- patch outline


On Nov 22, 2004, at 1:39 PM, Joe Buck wrote:

On Mon, Nov 22, 2004 at 01:23:22PM -0800, Matt Austern wrote:
Unfortunately, there is another reason for allowing some tamed version
of assignment to casts: compatibility with other compilers. Microsoft
and CodeWarrior both allow this in one form or another. (Microsoft for
C only, CodeWarrior for C++ as well. CodeWarrior only allows some
limited forms of assignments to casts, and doesn't treat a cast as a
true lvalue, so they still get overload resolution right.)

Does CodeWarrior document the semantics of their extension?

I'm trying to find that out. It's taking me a while, I'm afraid, partly because I'm not all that familiar with their documentation. I agree that's an important question. Another important question that I don't know the answer to: are there other compilers that accept some form of this extension? I wouldn't be surprised; lots of people have MS-compatibility modes.


One oddity I've found is that CW allows this:
  int x;
  int* p = x;
  char c;
  (char*) p = &c;

but not this:
  int x;
  (char) x = 'a';

And, as I said, they do choose the correct overload when you pass ((char*) p) to a function that's overloaded on char*& and char* const&.

--Matt


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