On Wed, 24 Jun 2009, Xavi wrote: > Uff, with g++ (TDM-1 mingw32) 4.4.0 > Set HB_USER_CFLAGS=-fno-strict-aliasing > :)
It may strongly reduce performance in some cases. It disables important source code optimizations. Please also note that it does not effect ANSI C code. Any code which needs -fno-strict-aliasing tp pacify warnings is not strictly ANSIC C compatible. best regards, Przemek > <--- source/vm/maindllp.c (429) ---> > return (char*)""; > <----------------------------------> > <--- source/vm/maindllp.c (454) ---> > return (char*)""; > <----------------------------------> > <--- contrib/hbct/ctnet.c (177) ---> > HB_FUNC( NETPRINTER ) > { > const char * cPrn = hb_setGetCPtr( HB_SET_PRINTFILE ); /* query default > local printer port. */ > > if( !cPrn || !*cPrn || hb_stricmp( cPrn, "PRN" ) == 0 ) > cPrn = "LPT1"; > hb_retl( hb_IsNetShared( (LPSTR)cPrn ) ); > } > <----------------------------------> > <--- contrib/hbct/print.c (204) ---> > char * szPort = (char*)"lpt1"; > char * szChr = (char*)" "; > <----------------------------------> > Placing and removing the flag HB_BUILD_MODE=cpp I don't have warning, please > test. Such code is wrong: char * szPort = "lpt1"; it should be changed to: const char * szPort = "lpt1"; strings allocated by simple "" quoting can be allocated in readonly are. If they are later passed to some other functions and modified on platforms with meory protection we will have GPF so the warnings are perfectly valid. Additionally C compiler for const char * varlues can make some additional optimizations, f.e.: pItem1 = hb_itemPutCL( NULL, szValue, strlen( szValue ) ); szDup = hb_strndup( szValue, strlen( szValue ) ); in the above code when szValue is declared as 'const char *' compiler can execute strlen( szValue ) only once and use it in two places. Such optimization is illegal when szValue is declared as simple 'char *'. There are also many other places which can be optimized, f.e.: while( szValue[ i ] )( { func1( szValue, i ) if( szValue[ i ] == 'x' ) func2( szValue ) elseif( szValue[ i ] & 0x20 ) func3( szValue, szValue[ i ] * 2 ) elseif( szValue[ i ] == 'y' ) func4( szValue, szValue[ i ] + 3 ) else func5( szValue, szValue[ i ] * 5 ) ++i; } in this code compiler can keep szValue[ i ] in register which is not destroyed by function call and use this register immediately instead of szValue[ i ]. But if szValue is not const then such optimization is illegal, etc. best regards, Przemek _______________________________________________ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour