Re: Why does gcc4 dislike this code?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





walt wrote:
Brian Dessent wrote:
walt wrote:

   *((unsigned long int *) tmp)++ = *((unsigned long int *) b1)++;

error: invalid lvalue in increment

The lvalue cast was a nonstandard gcc extension that was removed in 3.4;
in other words this is not valid standard C/C++.

http://gcc.gnu.org/gcc-3.4/changes.html

Wow, that was fast, thanks.  I'm quite sure I'd never write code
like that in the first place, mostly because it would never occur
to me to try it.  If you had to fix that code, how would you do it?

I'm no expert, but I would expand and simplify it.

I don't know if C defines in what order the increments will occur
on either side of the = ?

So write it out explicitly - don't leave it to the compiler and
assumptions.

And maybe declare tmp and b1 fully, instead of casting.

John.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux