Re: Invalid cast

2007-02-06 Thread Frederic Mayot
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(c); I also forgot to tell that this kind

Re: Invalid cast

2007-02-06 Thread Alf P. Steinbach
* Frederic Mayot: Hi, Can someone give me an explanation why the following code produces a bug. I think it's related to the compiler and that the first line is not OK. I have no pb with gcc 3.4 but the bug appeared with gcc 4.1.1 A* p = ...; int l; (char*&)p += l; The right way is p = reinterpret

Invalid cast

2007-02-06 Thread Frederic Mayot
Hi, Can someone give me an explanation why the following code produces a bug. I think it's related to the compiler and that the first line is not OK. I have no pb with gcc 3.4 but the bug appeared with gcc 4.1.1 A* p = ...; int l; (char*&)p += l; The right way is p = reinterpret_cast(reinterpret_ca