Re: oversensitive "use of cast expressions as lvalues is deprecated"

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

 



Shaun Jackman <sjackman@xxxxxxxxx> writes:

> The following statement is the result of a macro expansion (hence
> all the extra parenthesis). gcc's giving me a new warning about
> using a casted lvalue. I don't see where there is a casted lvalue
> here. The rhs of the assigment is an rvalue, so I'll ignore
> that. port is casted, but it's an rvalue at this point. Once it's
> dereferenced it's an lvalue, but there's no further casting after
> that. What's gone wrong here?
>
> int port;
> const void* src;
> (*((volatile uint16_t*)(port)) = (*((uint16_t *) src)++));

The casted lvalue is ((uint16_t *) src). The increment operator needs
a proper lvalue.

By the way, accessing nonvolatile objects through a volatile object
pointer is dangerous. It might do what you want, but is not guaranteed
to.

-- 
	Falk

[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