Bug 3470 - unzip.c compile fails Solaris/SPARC with Sun C compiler
Status: RESOLVED FIXED
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Misc
Version: GIT MASTER
Hardware: Sun Solaris
: P3 minor
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2007-12-11 15:19 EST by Patrick Baggett
Modified: 2007-12-11 16:20:01 EST
0 users

See Also:


Attachments
Fix incorrect pointer typecast as mentioned. (479 bytes, patch)
2007-12-11 15:21 EST, Patrick Baggett

Description Patrick Baggett 2007-12-11 15:19:43 EST
I have modified the default makefile to use Sun's C compiler instead of GCC like the maintainer Vincent uses since Sun's C compiler generally produces much better code than GCC. In the compilation process, unzip.c had an error about converting from void* type to a function pointer type on line 4051.

inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w))

Changing the Z_NULL (which is of type void*), to the correct typedef'd function pointer type as used by inflate_blocks_new()'s prototype fixes the error. 

inflate_blocks_new(z, z->state->nowrap ? ((check_func)0) : adler32, (uInt)1 << w))

Reasoning: ISO C forbids the typecast from data pointer to function pointer. Sun's C compiler refuses to output just a warning and instead raises it to an error status when seen. GCC and MSVC usually emit a warning that notes that this is actually forbidded by the C standard. To me honestly, pointers are pointers, but the ISO C standard also gives aliasing rules based on typecasts between types (see http://mail-index.netbsd.org/tech-kern/2003/08/11/0001.html for information/examples), and technically it is possible for the compiler to legally output incorrect code in such mentioned cases.

Reported against revision 1232.

Patrick Baggett
Figgle Software
Comment 1 Patrick Baggett 2007-12-11 15:21:34 EST
Created attachment 1619 [details]
Fix incorrect pointer typecast as mentioned.
Comment 2 Tim Angus 2007-12-11 16:20:01 EST
Fixed in r1233.