[Bug c/51741] complicatet brakets wont compile

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 3 15:25:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51741

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-01-03 15:25:32 UTC ---
The bug reporting guidelines at http://gcc.gnu.org/bugs/ ask for the following
which you have not provided:

* the exact version of gcc
* the exact command line
* the complete preprocessed source, not some code snippets (what is pos?)


(In reply to comment #0)
>    (&((knot*)((((*pos).branches)[i]).where)))
> 
> (compiler sas lvaluve needed for unary & operator)

The compiler is correct.  The cast to (knot*) creates an rvalue, so you cannot
take its address.

>     ((knot**)(&((((*pos).branches)[i]).where)))

Here you take the address of an lvalue, then cast it to (knot**), that's legal.

> will.
> both seem like legal C to me.

No, the first one is not. The bug is in your code, not GCC.


>    (((knot*)((((*pos).branches)[0]).where)).father)=pos;
> 
> won't compile .
> compiler thinks I try to adress .father for something thats not a structure or
> a union. even though I castet it to a knot* before trying to adress .father.

Maybe you mean ->father not .father.

Just because your code doesn't compile, that doesn't mean it's a GCC bug.



More information about the Gcc-bugs mailing list