in reply to Re^7: supporting quads on 32 bit Perl
in thread supporting quads on 32 bit Perl

0.19 failed on Activestates build system http://ppm4.activestate.com/MSWin32-x86/5.12/1200/S/SA/SALVA/Math-Int64-0.19.d/log-20120601T213822.txt. INT64_MAX is only in a Platform SDK header called intsafe.h. That was introduced somewhere between Studio 2005 and Studio 2008. My Studio 2003 doesn't have it, ActiveState doesn't have it.I added
static char *right_b_error = "right-shift right operand is out +of bounds"; static char *right_error = "right shift overflows"; #ifndef INT64_MAX #define INT64_MAX _I64_MAX #endif #ifndef INT64_MIN #define INT64_MIN _I64_MIN #endif #ifndef UINT64_MAX #define UINT64_MAX _UI64_MAX #endif #ifndef UINT32_MAX #define UINT32_MAX _UI32_MAX #endif #include "strtoint64.h" #include "isaac64.h"
and that fixed the limit constants problem. There are still more problems. After fixing the limit constants problem I got this
Int64.c Int64.xs(254) : error C2059: syntax error : 'bad suffix on number' Int64.xs(254) : error C2146: syntax error : missing ')' before identif +ier 'p63' Int64.xs(254) : error C2144: syntax error : '<Unknown>' should be prec +eded by '< Unknown>' Int64.xs(254) : error C2144: syntax error : '<Unknown>' should be prec +eded by '< Unknown>' Int64.xs(254) : error C2143: syntax error : missing ')' before 'identi +fier' Int64.xs(254) : error C2059: syntax error : 'bad suffix on number' Int64.xs(255) : warning C4244: 'return' : conversion from 'NV' to 'int +64_t', pos sible loss of data Int64.xs(334) : error C2059: syntax error : 'bad suffix on number' Int64.xs(334) : error C2146: syntax error : missing ')' before identif +ier 'p64' Int64.xs(334) : error C2144: syntax error : '<Unknown>' should be prec +eded by '< Unknown>' Int64.xs(334) : error C2144: syntax error : '<Unknown>' should be prec +eded by '< Unknown>' Int64.xs(334) : error C2143: syntax error : missing ')' before 'identi +fier'
VC is complaining about these strange constants.
if (may_die_on_overflow && ((nv >= 0x1p63) || (nv < -0x1p63))) overflow(aTHX_ out +_of_bounds_error_s); return nv;
This isn't C89. http://msdn.microsoft.com/en-us/library/w9bk1wcy%28v=vs.80%29.aspx http://msdn.microsoft.com/en-us/library/2k2xf226%28v=vs.80%29. So this will never compile on Visual C unless its fixed. I don't know how to fix that myself. So what is 0x1p63 as a normal C literal?

Replies are listed 'Best First'.
Re^9: supporting quads on 32 bit Perl
by Corion (Patriarch) on Jun 02, 2012 at 16:24 UTC

    I haven't seen that constant either. Google finds me a message for gcc which seems to claim that it's a C99 thing for declaring floating point constants in hexadecimal. I found some discussion by example, which suggests to me that 0x1p63 could be 1E63.

    I'm not sure why things get different between 32bit mode and 64bit mode here, but maybe your code never compiled under VC64bit either.

      0x1p63 == 0x1 * 2**63

      I am not sure that this constant can be expressed in a portable way in base 10 as the atof function used internally by the compiler may return a lesser value due to internal rounding errors.

      There are other ways to generate this numbers precisely. For instance, 0x1p64 can be generated as 0x1p32 * 0x1p32 (any atof can parse 0x1p32 expressed in decimal precisely).

      Anyway, I have just added some conditional code for MS compilers that uses a different approach for limit checking not involving those constants. The new code is available from the GitHub repository.

      I have not tested the code myself as I don't have any system with that compiler, so will apreciate testing reports.

        Things are better, your github int64.xs compiled and nmake test passed.
        C:\Documents and Settings\Owner\Desktop\cpan libs\Math-Int64-0.19>nmak +e test Microsoft (R) Program Maintenance Utility Version 7.10.3077 Copyright (C) Microsoft Corporation. All rights reserved. C:\perl512\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_h +arness(0, 'blib\lib', 'blib\arch')" t/*.t t/as_int64.t ............ ok t/die_on_overflow.t ..... ok t/Math-Int64-Native.t ... ok t/Math-Int64.t .......... ok t/Math-UInt64-Native.t .. ok t/Math-UInt64.t ......... ok t/pods.t ................ skipped: Only the author needs to check that + POD docs are right All tests successful. Files=7, Tests=241, 1 wallclock secs ( 0.12 usr + 0.05 sys = 0.17 C +PU) Result: PASS C:\Documents and Settings\Owner\Desktop\cpan libs\Math-Int64-0.19>
        But the build was very noisy.
        cp lib/Math/Int64.pm blib\lib\Math\Int64.pm cp lib/Math/Int64/die_on_overflow.pm blib\lib\Math\Int64\die_on_overfl +ow.pm cp lib/Math/Int64/native_if_available.pm blib\lib\Math\Int64\native_if +_available.pm C:\perl512\bin\perl.exe C:\perl512\lib\ExtUtils\xsubpp -typemap C +:\perl512\lib\ExtUtils\typemap Int64.xs > Int64.xsc && C:\perl512\bi +n\perl.exe -MExtUtils::Command -e "mv" -- Int64.xsc Int64.c cl -c -I. -nologo -GF -W3 -Od -MD -Zi -DDEBUGGING -DWIN32 -D_CON +SOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMP +LICIT_SYS -DUSE_PERLIO -Od -MD -Zi -DDEBUGGING -DVERSION=\"0.19\" + -DXS_VERSION=\"0.19\" "-IC:\perl512\lib\CORE" -DINT64_BACKEND_NV I +nt64.c Int64.c Int64.xs(253) : warning C4244: 'initializing' : conversion from 'NV' t +o 'int64_t', possible loss of data Int64.xs(259) : warning C4244: 'return' : conversion from 'NV' to 'int +64_t', possible loss of data Int64.xs(339) : warning C4244: 'initializing' : conversion from 'NV' t +o 'uint64_t', possible loss of data Int64.xs(345) : warning C4244: 'return' : conversion from 'NV' to 'uin +t64_t', possible loss of data Int64.xs(355) : warning C4244: 'initializing' : conversion from 'int64 +_t' to 'IV', possible loss of data Int64.xs(360) : warning C4244: 'initializing' : conversion from 'int64 +_t' to 'UV', possible loss of data Int64.xs(364) : warning C4244: 'function' : conversion from 'int64_t' +to 'const NV', possible loss of data Int64.xs(370) : warning C4244: 'initializing' : conversion from 'uint6 +4_t' to 'UV', possible loss of data Int64.xs(373) : warning C4244: 'function' : conversion from 'uint64_t' + to 'const NV', possible loss of data Int64.xs(385) : warning C4244: 'initializing' : conversion from 'uint6 +4_t' to 'char', possible loss of data Int64.xs(502) : warning C4244: 'function' : conversion from 'int64_t' +to 'const IV', possible loss of data Int64.xs(526) : warning C4244: 'function' : conversion from 'uint64_t' + to 'const UV', possible loss of data Int64.xs(545) : warning C4244: '=' : conversion from 'int64_t' to 'cha +r', possible loss of data Int64.xs(563) : warning C4244: '=' : conversion from 'uint64_t' to 'ch +ar', possible loss of data Int64.xs(679) : warning C4244: 'function' : conversion from 'uint64_t' + to 'const IV', possible loss of data Int64.xs(690) : warning C4244: 'function' : conversion from 'uint64_t' + to 'const UV', possible loss of data Int64.xs(700) : warning C4244: 'function' : conversion from 'uint64_t' + to 'const IV', possible loss of data Int64.xs(710) : warning C4244: 'function' : conversion from 'uint64_t' + to 'const UV', possible loss of data Int64.xs(722) : warning C4244: 'function' : conversion from 'int64_t' +to 'const IV', possible loss of data Int64.xs(733) : warning C4244: 'function' : conversion from 'uint64_t' + to 'const IV', possible loss of data Int64.xs(756) : warning C4554: '<<' : check operator precedence for po +ssible error; use parentheses to clarify precedence Int64.c(1262) : warning C4101: 'rev' : unreferenced local variable Int64.c(1261) : warning C4101: 'other' : unreferenced local variable Int64.c(1290) : warning C4101: 'rev' : unreferenced local variable Int64.c(1289) : warning C4101: 'other' : unreferenced local variable Int64.c(1679) : warning C4101: 'rev' : unreferenced local variable Int64.c(1706) : warning C4101: 'rev' : unreferenced local variable Int64.c(1938) : warning C4101: 'rev' : unreferenced local variable Int64.c(1937) : warning C4101: 'other' : unreferenced local variable Int64.c(1963) : warning C4101: 'rev' : unreferenced local variable Int64.c(1962) : warning C4101: 'other' : unreferenced local variable Int64.c(1988) : warning C4101: 'rev' : unreferenced local variable Int64.c(1987) : warning C4101: 'other' : unreferenced local variable Int64.c(2013) : warning C4101: 'rev' : unreferenced local variable Int64.c(2012) : warning C4101: 'other' : unreferenced local variable Int64.c(2038) : warning C4101: 'rev' : unreferenced local variable Int64.c(2037) : warning C4101: 'other' : unreferenced local variable Int64.c(2063) : warning C4101: 'rev' : unreferenced local variable Int64.c(2062) : warning C4101: 'other' : unreferenced local variable Int64.c(2088) : warning C4101: 'rev' : unreferenced local variable Int64.c(2087) : warning C4101: 'other' : unreferenced local variable Int64.c(2113) : warning C4101: 'rev' : unreferenced local variable Int64.c(2112) : warning C4101: 'other' : unreferenced local variable Int64.c(2140) : warning C4101: 'rev' : unreferenced local variable Int64.c(2139) : warning C4101: 'other' : unreferenced local variable Int64.c(2505) : warning C4101: 'rev' : unreferenced local variable Int64.c(2532) : warning C4101: 'rev' : unreferenced local variable Int64.c(2764) : warning C4101: 'rev' : unreferenced local variable Int64.c(2763) : warning C4101: 'other' : unreferenced local variable Int64.c(2789) : warning C4101: 'rev' : unreferenced local variable Int64.c(2788) : warning C4101: 'other' : unreferenced local variable Int64.xs(1607) : warning C4146: unary minus operator applied to unsign +ed type, result still unsigned Int64.c(2814) : warning C4101: 'rev' : unreferenced local variable Int64.c(2813) : warning C4101: 'other' : unreferenced local variable Int64.c(2839) : warning C4101: 'rev' : unreferenced local variable Int64.c(2838) : warning C4101: 'other' : unreferenced local variable Int64.c(2864) : warning C4101: 'rev' : unreferenced local variable Int64.c(2863) : warning C4101: 'other' : unreferenced local variable Int64.c(2889) : warning C4101: 'rev' : unreferenced local variable Int64.c(2888) : warning C4101: 'other' : unreferenced local variable Int64.c(2914) : warning C4101: 'rev' : unreferenced local variable Int64.c(2913) : warning C4101: 'other' : unreferenced local variable c:\documents and settings\owner\desktop\cpan libs\math-int64-0.19\int6 +4.xs(602) : warning C4700: local variable 'RETVAL' used without havin +g been initialized c:\documents and settings\owner\desktop\cpan libs\math-int64-0.19\int6 +4.xs(167) : warning C4715: 'SvSI64' : not all control paths return a +value c:\documents and settings\owner\desktop\cpan libs\math-int64-0.19\int6 +4.xs(177) : warning C4715: 'SvSU64' : not all control paths return a +value Running Mkbootstrap for Math::Int64 () C:\perl512\bin\perl.exe -MExtUtils::Command -e "chmod" -- 644 Int6 +4.bs C:\perl512\bin\perl.exe -MExtUtils::Mksymlists -e "Mksymlists('NA +ME'=>\"Math::Int64\", 'DLBASE' => 'Int64', 'DL_FUNCS' => { }, 'FUNCL +IST' => [], 'IMPORTS' => { }, 'DL_VARS' => []);" link -out:blib\arch\auto\Math\Int64\Int64.dll -dll -nologo -nodefa +ultlib -debug -libpath:"c:\perl512\lib\CORE" -machine:x86 Int64.obj + C:\perl512\lib\CORE\perl512.lib oldnames.lib kernel32.lib user32.l +ib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole3 +2.lib oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.li +b version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib -def:I +nt64.def Creating library blib\arch\auto\Math\Int64\Int64.lib and object bli +b\arch\auto\Math\Int64\Int64.exp if exist blib\arch\auto\Math\Int64\Int64.dll.manifest mt -nologo - +manifest blib\arch\auto\Math\Int64\Int64.dll.manifest -outputresource +:blib\arch\auto\Math\Int64\Int64.dll;2 if exist blib\arch\auto\Math\Int64\Int64.dll.manifest del blib\arc +h\auto\Math\Int64\Int64.dll.manifest C:\perl512\bin\perl.exe -MExtUtils::Command -e "chmod" -- 755 blib +\arch\auto\Math\Int64\Int64.dll C:\perl512\bin\perl.exe -MExtUtils::Command -e "cp" -- Int64.bs bl +ib\arch\auto\Math\Int64\Int64.bs C:\perl512\bin\perl.exe -MExtUtils::Command -e "chmod" -- 644 blib +\arch\auto\Math\Int64\Int64.bs Files found in blib\arch: installing files in blib\lib into architectu +re dependent library tree Installing C:\perl512\site\lib\auto\Math\Int64\Int64.dll Installing C:\perl512\site\lib\auto\Math\Int64\Int64.exp Installing C:\perl512\site\lib\auto\Math\Int64\Int64.ilk Installing C:\perl512\site\lib\auto\Math\Int64\Int64.lib Installing C:\perl512\site\lib\auto\Math\Int64\Int64.pdb Appending installation info to c:\perl512\lib/perllocal.pod
        I don't know if any of these warnings are errors or just forgotten casts yet.

        edit: made a summary of the code thats causing all the warnings, 1 or 2 of them look like real bugs, my comments if any are all caps, >>>>>>> means the line the warning above is pointing to