Subject: Re: toolchain/29743: gcc optimisation hoses function pointer call
To: None <toolchain-manager@netbsd.org, gnats-admin@netbsd.org,>
From: Martin Husemann <martin@duskware.de>
List: netbsd-bugs
Date: 03/20/2005 07:50:01
The following reply was made to PR toolchain/29743; it has been noted by GNATS.

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/29743: gcc optimisation hoses function pointer call
Date: Sun, 20 Mar 2005 08:49:32 +0100

 This is no compiler bug. The file is indirectly compile in=20
 xfree/xc/lib/freetype2, with this compiler call:
 
 gcc -c -O2 -ansi -Dasm=3D__asm -I. -I../../extras/freetype2/src -I../../ext=
 ras/freetype2/src/base -I../../extras/freetype2/src/autofit -I../../extras/=
 freetype2/src/autohint -I../../extras/freetype2/src/bdf -I../../extras/free=
 type2/src/cff -I../../extras/freetype2/src/cid -I../../extras/freetype2/src=
 /gzip -I../../extras/freetype2/src/lzw -I../../extras/freetype2/src/pcf -I.=
 ./../extras/freetype2/src/pfr -I../../extras/freetype2/src/psaux -I../../ex=
 tras/freetype2/src/pshinter -I../../extras/freetype2/src/psnames -I../../ex=
 tras/freetype2/src/raster -I../../extras/freetype2/src/sfnt -I../../extras/=
 freetype2/src/smooth -I../../extras/freetype2/src/truetype -I../../extras/f=
 reetype2/src/type1 -I../../extras/freetype2/src/type42 -I../../extras/freet=
 ype2/src/winfonts -I../../exports/include -I../../exports/include/freetype2=
  -I../../exports/include/X11 -I../.. -I../../exports/include -DCSRG_BASED -=
 DFUNCPROTO=3D15 -DNARROWPROTO -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -DX=
 NO_MTSAFE_PWDAPI -DXFREE86_FT2 -fPIC ftbase.c
 
 (not there are lots of symlinks in the current directory at this point).
 
 Adding -Wall to this call gives:
 
 In file included from ftbase.c:23:
 =2E./../extras/freetype2/src/base/ftutil.c: In function `FT_List_Finalize':
 =2E./../extras/freetype2/src/base/ftutil.c:321: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 In file included from ftbase.c:29:
 =2E./../extras/freetype2/src/base/ftgloadr.c: In function `FT_GlyphLoader_N=
 ew':
 =2E./../extras/freetype2/src/base/ftgloadr.c:76: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftgloadr.c: In function `FT_GlyphLoader_D=
 one':
 =2E./../extras/freetype2/src/base/ftgloadr.c:133: warning: dereferencing ty=
 pe-punned pointer will break strict-aliasing rules
 In file included from ftbase.c:30:
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_Stream_New':
 =2E./../extras/freetype2/src/base/ftobjs.c:128: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:152: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:159: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_Stream_Free':
 =2E./../extras/freetype2/src/base/ftobjs.c:182: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `ft_glyphslot_init':
 =2E./../extras/freetype2/src/base/ftobjs.c:216: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_New_GlyphSlot':
 =2E./../extras/freetype2/src/base/ftobjs.c:358: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:366: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_Done_GlyphSlot':
 =2E./../extras/freetype2/src/base/ftobjs.c:402: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `destroy_size':
 =2E./../extras/freetype2/src/base/ftobjs.c:672: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `destroy_face':
 =2E./../extras/freetype2/src/base/ftobjs.c:746: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `open_face':
 =2E./../extras/freetype2/src/base/ftobjs.c:885: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:888: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:938: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:939: warning: dereferencing type=
 -punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `new_memory_stream':
 =2E./../extras/freetype2/src/base/ftobjs.c:1068: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `open_face_from_buf=
 fer':
 =2E./../extras/freetype2/src/base/ftobjs.c:1105: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:1124: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `Mac_Read_POST_Reso=
 urce':
 =2E./../extras/freetype2/src/base/ftobjs.c:1172: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:1241: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `Mac_Read_sfnt_Reso=
 urce':
 =2E./../extras/freetype2/src/base/ftobjs.c:1284: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `IsMacResource':
 =2E./../extras/freetype2/src/base/ftobjs.c:1339: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:1351: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_Open_Face':
 =2E./../extras/freetype2/src/base/ftobjs.c:1670: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_Done_Face':
 =2E./../extras/freetype2/src/base/ftobjs.c:1821: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_New_Size':
 =2E./../extras/freetype2/src/base/ftobjs.c:1863: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:1863: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:1885: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:1886: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_Done_Size':
 =2E./../extras/freetype2/src/base/ftobjs.c:1923: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_CMap_Done':
 =2E./../extras/freetype2/src/base/ftobjs.c:2231: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_CMap_New':
 =2E./../extras/freetype2/src/base/ftobjs.c:2254: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_Get_Name_Index':
 =2E./../extras/freetype2/src/base/ftobjs.c:2374: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_Get_Glyph_Name':
 =2E./../extras/freetype2/src/base/ftobjs.c:2408: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_Get_Postscript_=
 Name':
 =2E./../extras/freetype2/src/base/ftobjs.c:2436: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_Get_Sfnt_Table':
 =2E./../extras/freetype2/src/base/ftobjs.c:2461: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_Load_Sfnt_Table=
 ':
 =2E./../extras/freetype2/src/base/ftobjs.c:2485: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_Get_CMap_Langua=
 ge_ID':
 =2E./../extras/freetype2/src/base/ftobjs.c:2505: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `ft_add_renderer':
 =2E./../extras/freetype2/src/base/ftobjs.c:2626: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:2658: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `ft_remove_renderer=
 ':
 =2E./../extras/freetype2/src/base/ftobjs.c:2685: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `Destroy_Module':
 =2E./../extras/freetype2/src/base/ftobjs.c:2885: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_Add_Module':
 =2E./../extras/freetype2/src/base/ftobjs.c:2941: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:3011: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_New_Library':
 =2E./../extras/freetype2/src/base/ftobjs.c:3179: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c:3195: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftobjs.c: In function `FT_Done_Library':
 =2E./../extras/freetype2/src/base/ftobjs.c:3275: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 In file included from ftbase.c:32:
 =2E./../extras/freetype2/src/base/ftrfork.c: In function `FT_Raccess_Get_Da=
 taOffsets':
 =2E./../extras/freetype2/src/base/ftrfork.c:183: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftrfork.c:193: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftrfork.c: In function `raccess_guess_dar=
 win_ufs_export':
 =2E./../extras/freetype2/src/base/ftrfork.c:411: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftrfork.c: In function `raccess_guess_dar=
 win_hfsplus':
 =2E./../extras/freetype2/src/base/ftrfork.c:436: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftrfork.c: In function `raccess_guess_lin=
 ux_double':
 =2E./../extras/freetype2/src/base/ftrfork.c:526: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftrfork.c: In function `raccess_guess_lin=
 ux_netatalk':
 =2E./../extras/freetype2/src/base/ftrfork.c:558: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 =2E./../extras/freetype2/src/base/ftrfork.c: In function `raccess_make_file=
 _name':
 =2E./../extras/freetype2/src/base/ftrfork.c:665: warning: dereferencing typ=
 e-punned pointer will break strict-aliasing rules
 
 So, we should either add -fno-strict-aliasing to CFLAGS or -Wall and fix all
 the problems. Reducing -O2 to -O1 would avoid the problem too. Maybe=20
 investigate if this is a new problem or what the pkgsrc freetype2 does firs=
 t.
 
 Martin