Mailinglist Archive: opensuse-packaging (80 mails)

< Previous Next >
Re: [opensuse-packaging] strict-aliasing and dlsym
  • From: Cristian Rodríguez <crrodriguez@xxxxxxxxxxxx>
  • Date: Fri, 13 Aug 2010 14:15:33 -0400
  • Message-id: <4C658BC5.9080500@xxxxxxxxxxxx>
El 13/08/10 13:44, Cristian Morales Vega escribió:
Hi,

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?

Even the example code in the manual triggers the warning, matz will
probably know where the bug really is ;)
--
To unsubscribe, e-mail: opensuse-packaging+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-packaging+help@xxxxxxxxxxxx

< Previous Next >