Mailinglist Archive: opensuse-packaging (80 mails)

< Previous Next >
[opensuse-packaging] strict-aliasing and dlsym
  • From: Cristian Morales Vega <cmorve69@xxxxxxxx>
  • Date: Fri, 13 Aug 2010 19:44:38 +0200
  • Message-id: <AANLkTi=ADc7vHpemAEaEftt1Sk_gNwQKi=fBR3QJu+7L@xxxxxxxxxxxxxx>

I'm getting
"comp.c:42:3: warning: dereferencing type-punned pointer will break
strict-aliasing rules"

that translates to

"I: Program is likely to break with new gcc. Try -fno-strict-aliasing.
W: sipp strict-aliasing-punning comp.c:42, 46, 50"

through post-build-checks.

The thing is the offending code is

"*(void **)(&comp_compress) = dlsym(handle, "comp_compress");"

And the man page of dlsym explicitly says that is the correct way to do it:

/* Writing: cosine = (double (*)(double)) dlsym(handle, "cos");
would seem more natural, but the C99 standard leaves
casting from "void *" to a function pointer undefined.
The assignment used below is the POSIX.1-2003 (Technical
Corrigendum 1) workaround; see the Rationale for the
POSIX specification of dlsym(). */

So, the question: could gcc -O2 really break that code? Or that's a
false warning and I can be 100% safe ignoring it?

To unsubscribe, e-mail: opensuse-packaging+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-packaging+help@xxxxxxxxxxxx

< Previous Next >