[collectd] [PATCH] libiptc: avoid strict-aliasing warnings

Alan Pevec apevec at gmail.com
Tue Mar 9 21:39:02 CET 2010


On Tue, Mar 9, 2010 at 5:09 PM, Florian Forster <octo at verplant.org> wrote:
> Hi Alan, hi Jan,
>
> On Tue, Feb 16, 2010 at 09:16:47PM +0100, Alan Pevec wrote:
>> -             int pos = *(int *)t->data;
>> +             const unsigned char *data = t->data;
>> +             int pos = *(const int *)data;
>
> I have to admit these changes look a bit like "cast to different types
> until the compiler is confused", but I don't see any problem arising
> from those casts either. So if it's fixing a problem for you, it's fine
> by me. I've applied the changes to the collectd-4.8 branch.

Thanks!
Well, this was breaking collectd build in Fedora, so I just took the
upstream patch without much thinking.
strict-aliasing is confusing indeed, AFAICT solution by Jan is that
char* is special and may refer any type.

> I assume that's GCC throwing those warnings? Just out of curiosity, what
> version is that?

It's the latest Fedora gcc, currently that's gcc-4.4.3-8
http://koji.fedoraproject.org/koji/packageinfo?packageID=40

Alan



More information about the collectd mailing list