Discussion:
FVWM: Patch: fix type-punned will break strict anti-aliasing
walter harms
2014-02-09 16:05:13 UTC
Permalink
hi List,
i got some warnings about "strict anti-aliasing". It was easy to fix and should not
break other things.

re,
wh


--- Colorset.c~ 2008-02-05 22:04:47.000000000 +0100
+++ Colorset.c 2013-12-22 21:54:48.000000000 +0100
@@ -233,12 +233,13 @@
{
Pixmap pixmap = None;
Pixmap mask = None;
- XID junk;
+ int junk;
+ XID root;

if (0 == width || 0 == height)
{
if (!XGetGeometry(
- dpy, win, &junk, (int *)&junk, (int *)&junk,
+ dpy, win, &root, (int *)&junk, (int *)&junk,
(unsigned int *)&width, (unsigned int *)&height,
(unsigned int *)&junk, (unsigned int *)&junk))
{
@@ -423,12 +424,13 @@
if (CSETS_IS_TRANSPARENT_ROOT_PURE(colorset))
{
/* check if it is still here */
- XID dummy;
+ int dummy;
+ XID root;
/* a priori we should grab the server, but this
* cause PositiveWrite error when you move a
* window with a transparent title bar */
if (!XGetGeometry(
- dpy, colorset->pixmap, &dummy,
+ dpy, colorset->pixmap, &root,
(int *)&dummy, (int *)&dummy,
(unsigned int *)&w, (unsigned int *)&h,
(unsigned int *)&dummy,
Dan Espen
2014-02-09 22:00:13 UTC
Permalink
Post by walter harms
hi List,
i got some warnings about "strict anti-aliasing". It was easy to fix and should not
break other things.
--- Colorset.c~ 2008-02-05 22:04:47.000000000 +0100
+++ Colorset.c 2013-12-22 21:54:48.000000000 +0100
@@ -233,12 +233,13 @@
{
Pixmap pixmap = None;
Pixmap mask = None;
- XID junk;
+ int junk;
+ XID root;
Hi,

How did you get the warning? I don't get one with "-Wall -Werror".

I like clean looking compiles, but this one actually adds
4 unnecessary bytes to the stack. I know that's very minor
but it goes against my grain. I'm guessing this could be
fixed with a union too which would eliminate the 4 bytes.
But I hesitate to do anything without seeing the messages first.
--
Dan Espen
walter harms
2014-02-10 08:26:04 UTC
Permalink
hi,
actually i did nothing special, NTL i used an older GCC version
and they change there setup sometimes. Soon i have time i will
check the gcc version in question. If you do not see an answer
until Wednesday ping me again.

re,
wh
Post by Dan Espen
Post by walter harms
hi List,
i got some warnings about "strict anti-aliasing". It was easy to fix and should not
break other things.
--- Colorset.c~ 2008-02-05 22:04:47.000000000 +0100
+++ Colorset.c 2013-12-22 21:54:48.000000000 +0100
@@ -233,12 +233,13 @@
{
Pixmap pixmap = None;
Pixmap mask = None;
- XID junk;
+ int junk;
+ XID root;
Hi,
How did you get the warning? I don't get one with "-Wall -Werror".
I like clean looking compiles, but this one actually adds
4 unnecessary bytes to the stack. I know that's very minor
but it goes against my grain. I'm guessing this could be
fixed with a union too which would eliminate the 4 bytes.
But I hesitate to do anything without seeing the messages first.
walter harms
2014-02-10 18:05:43 UTC
Permalink
/home/walter/src/fvwm/libs
make[2]: Entering directory `/home/walter/src/fvwm/libs'
gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I/usr/include -I/usr/include/freetype2 -I/usr/include/librsvg-2 -I/usr/include/gnome-vfs-2.0
-I/usr/lib/gnome-vfs-2.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/include/cairo
-I/usr/include/freetype2 -I/usr/include/libpng12 -Wall -Wno-implicit-int -g -O2 -MT PictureGraphics.o -MD -MP -MF
.deps/PictureGraphics.Tpo -c -o PictureGraphics.o PictureGraphics.c
PictureGraphics.c: In function ‘PGraphicsCreateTransparency’:
PictureGraphics.c:1240: warning: dereferencing type-punned pointer will break strict-aliasing rules
PictureGraphics.c:1240: warning: dereferencing type-punned pointer will break strict-aliasing rules
PictureGraphics.c:1242: warning: dereferencing type-punned pointer will break strict-aliasing rules
PictureGraphics.c:1242: warning: dereferencing type-punned pointer will break strict-aliasing rules
mv -f .deps/PictureGraphics.Tpo .deps/PictureGraphics.Po


gcc -v
Using built-in specs.
Target: i586-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release
--with-gxx-include-dir=/usr/include/c++/4.2.1 --enable-ssp --disable-libssp --disable-libgcj --with-slibdir=/lib --with-system-zlib
--enable-shared --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --program-suffix=-4.2
--enable-version-specific-runtime-libs --without-system-libunwind --with-cpu=generic --host=i586-suse-linux
Thread model: posix
gcc version 4.2.1 (SUSE Linux)

You may like to read this why -Wall does not automaticly show this:
http://blog.worldofcoding.com/2010/02/solving-gcc-44-strict-aliasing-problems.html

The whole point of fixing things is that i may cause subtil errors.

re,
wh
Post by Dan Espen
Post by walter harms
hi List,
i got some warnings about "strict anti-aliasing". It was easy to fix and should not
break other things.
--- Colorset.c~ 2008-02-05 22:04:47.000000000 +0100
+++ Colorset.c 2013-12-22 21:54:48.000000000 +0100
@@ -233,12 +233,13 @@
{
Pixmap pixmap = None;
Pixmap mask = None;
- XID junk;
+ int junk;
+ XID root;
Hi,
How did you get the warning? I don't get one with "-Wall -Werror".
I like clean looking compiles, but this one actually adds
4 unnecessary bytes to the stack. I know that's very minor
but it goes against my grain. I'm guessing this could be
fixed with a union too which would eliminate the 4 bytes.
But I hesitate to do anything without seeing the messages first.
Dan Espen
2014-02-12 04:53:31 UTC
Permalink
Post by walter harms
/home/walter/src/fvwm/libs
PictureGraphics.c:1240: warning: dereferencing type-punned pointer will break strict-aliasing rules
...
Post by walter harms
http://blog.worldofcoding.com/2010/02/solving-gcc-44-strict-aliasing-problems.html
The whole point of fixing things is that i may cause subtil errors.
Adding the flag -Wstrict-aliasing=2 I got quite a few errors.
More than the patch addressed.

I fixed Colorset.c with a union instead of additional data areas.

I got warnings in at least one other module but haven't committed
changes. Yet.

Thanks.
--
Dan Espen
Loading...