[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: Problems with PCB



> What is a "type punned pointer", and are we doing anything dangerous with them?

struct grill x;
((struct foo)x).bar = 5;
or
struct grill *x;
((struct foo *)x)->bar = 5;

Changing the type of an object on the left side of an assignment has
become a violation of strict aliasing rules, and newer GCCs use
aliasing during optimization.  Thus, gcc may not properly realize that
a value has been overwritten by such an assignment, and use an old
value instead of the (correct) new value.

What you're supposed to do is use "void *" as your intermediate value,
not a pointer to some specific type.

> Is there a portable way to printf a size_t?

Cast it to a long and use %ld is portable enough for us.


_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user