[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Invalid cast
From: |
Frederic Mayot |
Subject: |
Re: Invalid cast |
Date: |
6 Feb 2007 10:40:50 -0800 |
User-agent: |
G2/1.0 |
Thanks a lot for correcting my English. Next time, I will explicitly
ask for a technical answer ;-)
In the code I gave, the memory area between p and (char*)p + l is
valid. Let's suppose that we have
char* c = new char[M]; // M > l
A* p = reinterpret_cast<A*>(c);
I also forgot to tell that this kind of code is used in an allocator.
So please don't tell me that reinterpret_casts are not appropriate in
that case.
I just wondered why
(char*&)p += l;
could be differently compiled than
p = reinterpret_cast<A*>(reinterpret_cast<char*>(p) + l);
If you don't know, kindly avoid answers like "this is not defined in
the C++ standard"
(My message was also posted to gnu.gcc.help and gnu.g++.help)