#30573 [NEW]: Compiler Warning Due to Invalid Incorrect Type Cast

From: Date: Wed, 27 Oct 2004 02:10:20 +0000
Subject: #30573 [NEW]: Compiler Warning Due to Invalid Incorrect Type Cast
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-68373@lists.php.net to get a copy of this message
From: jbarwick at sentienthealth dot com Operating system: SuSE9.1 (amd64) PHP version: 4.3.8 PHP Bug Type: Compile Warning Bug description: Compiler Warning Due to Invalid Incorrect Type Cast Description: ------------ file in consideration: ext/mbstring/libmbfl/filters/mbfilter_htmlent.c line 156 The line in question is written as: filter->cache = (int)mbfl_malloc(html_enc_buffer_size+1); This line is invalid on 64 bit systems as mbfl_malloc should be returning a pointer (64 bit) and int is not... filter->cache is defined as a long ... questions, should it be ulong? don't wanna change it cuz I don't know if there is any negative math used here.... Anyway, if we rewrite the line to: filter->cache = (long)mbfl_malloc(html_enc_buffer_size+1); we fix the invalid data type size, and this WILL work on both 32 bit and 64 bit systems. Throwing away the top 32 bits of a 64 bit pointer is extremely dangerous...don't you think? Reproduce code: --------------- compile the source Expected result: ---------------- no compiler warnings Actual result: -------------- compiler warnings: cast from pointer ot integer of different size.. -- Edit bug report at http://bugs.php.net/?id=30573&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30573&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30573&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30573&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30573&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30573&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30573&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30573&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30573&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30573&r=support Expected behavior: http://bugs.php.net/fix.php?id=30573&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30573&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30573&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30573&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30573&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30573&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30573&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30573&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30573&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30573&r=mysqlcfg

« previous php.bugs (#68373) next »