32 bit fixes (#10608)

This commit is contained in:
Arne Döring 2019-02-12 22:00:31 +01:00 • committed by Andreas Rumpf
commit 6870345cd2
26 changed files with 165 additions and 135 deletions

View file

@ -65,14 +65,14 @@ expression: f(y)
'''
errormsg: "type mismatch: got <MatchingType>"
line: 138
disabled: 32bit
"""
# disabled on 32 bit, because the order of suggested alternatives ``r`` differs
# proc r[T](a: SomeNumber; b: T; c: auto)
# proc r(i: string): int
# proc r(o: RegularConcept): int

View file

@ -1,6 +1,8 @@
# bug #3799
discard """
output: '''
import strutils
const output = splitLines("""
00000000000000000000000000000000000000000
00000000000001111111111111110000000000000
00000000001111111111111111111110000000000
@ -28,11 +30,7 @@ output: '''
00000000111111111111111111111111100000000
00000000000111111111111111111100000000000
00000000000000111111111111100000000000000
'''
"""
import macros
""")
const nmax = 500
@ -63,19 +61,25 @@ proc julia*[T](z0, c: Complex[T], er2: T, nmax: int): int =
template dendriteFractal*[T](z0: Complex[T], er2: T, nmax: int): int =
julia(z0, (T(0.0), T(1.0)), er2, nmax)
iterator stepIt[T](start, step: T, iterations: int): T =
iterator stepIt[T](start, step: T, iterations: int): (int, T) =
for i in 0 .. iterations:
yield start + T(i) * step
yield (i, start + T(i) * step)
var errors = 0
let c = (0.36237, 0.32)
for y in stepIt(2.0, -0.0375 * 4, 107 div 4):
for j, y in stepIt(2.0, -0.0375 * 4, 107 div 4):
var row = ""
for x in stepIt(-2.0, 0.025 * 4, 160 div 4):
for i, x in stepIt(-2.0, 0.025 * 4, 160 div 4):
#let n = julia((x, y), c, 4.0, nmax) ### this works
let n = dendriteFractal((x, y), 4.0, nmax)
if n < nmax:
row.add($(n mod 10))
else:
row.add(' ')
echo row
let c = char(int('0') + n mod 10)
let e = output[j][i] # expected
if c != e:
errors += 1
row.add(c)
# Printing aparently makes the test fail when joined.
# echo row
doAssert errors < 10, "total errors: " & $errors

View file

@ -1,7 +1,7 @@
discard """
tfile: "tenummix.nim"
tline: 11
errormsg: "type mismatch"
file: "tenummix.nim"
line: 11
"""
type

View file

@ -16,9 +16,12 @@ proc rsplit(s: string; sep: string; maxsplit: int = -1): seq[string]
expression: rsplit("abc:def", {':'}, maxsplits = 1)
'''
disabled: 32bit
"""
# bug #8043
# disabled on 32 bit systems because the order of suggested proc alternatives is different.
import strutils
"abc:def".rsplit({':'}, maxsplits = 1)

View file

@ -3,8 +3,10 @@ discard """
[0, 0]'''
target: "c"
joinable: false
disabled: 32bit
"""
# this test wasn't written for 32 bit
# don't join because the code is too messy.
# Nim RTree and R*Tree implementation

View file

@ -246,6 +246,9 @@ proc main() =
r: PRadixNode = nil
for x in items(numbers):
echo testOrIncl(r, x)
for x in elements(r): echo(x)
for x in elements(r):
# ByteAddress being defined as a signed integer cases trouble
# exactly here
echo(cast[uint](x))
main()

View file

@ -279,6 +279,11 @@ testinstance:
InheritanceC {.objectconfig.} = object of InheritanceB
c: char
# from issue 4763
GenericObject[T] = object
a: int32
b: T
#Float128Test = object
# a: byte
# b: float128
@ -298,6 +303,7 @@ testinstance:
var f : PaddingAfterBranch
var g : RecursiveStuff
var ro : RootObj
var go : GenericObject[int64]
var
e1: Enum1
@ -311,7 +317,7 @@ testinstance:
testAlign(SimpleAlignment)
testSizeAlignOf(t,a,b,c,d,e,f,g,ro, e1, e2, e4, e8, eoa, eob)
testSizeAlignOf(t,a,b,c,d,e,f,g,ro,go, e1, e2, e4, e8, eoa, eob)
when not defined(cpp):
type
@ -414,6 +420,28 @@ type
doAssert sizeof(MixedBitsize) == 12
##########################################
# bug #9794
##########################################
type
imported_double {.importc: "double".} = object
Pod = object
v* : imported_double
seed*: int32
Pod2 = tuple[v: imported_double, seed: int32]
proc foobar() =
testAlign(Pod)
testSize(Pod)
testAlign(Pod2)
testSize(Pod2)
doAssert sizeof(Pod) == sizeof(Pod2)
doAssert alignof(Pod) == alignof(Pod2)
foobar()
if failed:
quit("FAIL")
else:

View file

@ -1,10 +1,7 @@
discard """
output: '''TBar2
TFoo
16
12
16
12'''
'''
"""
## XXX this output needs to be adapated for VCC which produces different results.
@ -67,29 +64,6 @@ var aa = makeWindow()
thisCausesError(dd, aa)
# bug #4763
type
testObject_1 = object
size: int32
value: int64
testObject_2 {.packed.} = object
size: int32
value: int64
testObject_3[T] = object
size: int32
value: T
testObject_4 {.packed.} [T] = object
size: int32
value: T
echo sizeof(testObject_1)
echo sizeof(testObject_2)
echo sizeof(testObject_3[int64])
echo sizeof(testObject_4[int64])
# bug #5892
type
Foo6 = distinct array[4, float32]

View file

@ -48,10 +48,10 @@ when defined(case_testfile): # compiled test file for child process
else:
import os, osproc, strutils, posix
const nim = getCurrentCompilerExe()
block execShellCmdTest:
## first, compile child program
const nim = getCurrentCompilerExe()
const sourcePath = currentSourcePath()
let output = buildDir / "D20190111T024543".addFileExt(ExeExt)
let cmd = "$# c -o:$# -d:release -d:case_testfile $#" % [nim, output,
@ -71,14 +71,10 @@ else:
runTest("exitnow_139", 139)
runTest("c_exit2_139", 139)
runTest("quit_139", 139)
runTest("exit_array", 1)
when defined(posix): # on windows, -1073741571
runTest("exit_recursion", SIGSEGV.int + 128) # bug #10273: was returning 0
assertEquals exitStatusLikeShell(SIGSEGV), SIGSEGV + 128.cint
block execProcessTest:
let dir = parentDir(currentSourcePath())
let (outp, err) = execCmdEx("nim c " & quoteShell(dir / "osproctest.nim"))
let (outp, err) = execCmdEx(nim & " c " & quoteShell(dir / "osproctest.nim"))
doAssert err == 0
let exePath = dir / addFileExt("osproctest", ExeExt)
let outStr1 = execProcess(exePath, workingDir = dir, args = ["foo",

View file

@ -2,6 +2,7 @@ discard """
disabled: "travis"
disabled: "appveyor"
joinable: false
disabled: 32bit
"""
# CI integration servers are out of memory for this test

View file

@ -5,40 +5,42 @@ joinable: false
# appveyor is "out of memory"
const
nmax = 2*1024*1024*1024
when sizeof(int) >= 8:
# no point to test this on system with smaller address space
const
nmax = 2*1024*1024*1024
proc test(n: int) =
var a = alloc0(9999)
var t = cast[ptr UncheckedArray[int8]](alloc(n))
var b = alloc0(9999)
t[0] = 1
t[1] = 2
t[n-2] = 3
t[n-1] = 4
dealloc(a)
dealloc(t)
dealloc(b)
proc test(n: int) =
var a = alloc0(9999)
var t = cast[ptr UncheckedArray[int8]](alloc(n))
var b = alloc0(9999)
t[0] = 1
t[1] = 2
t[n-2] = 3
t[n-1] = 4
dealloc(a)
dealloc(t)
dealloc(b)
# allocator adds 48 bytes to BigChunk
# BigChunk allocator edges at 2^n * (1 - s) for s = [1..32]/64
proc test2(n: int) =
let d = n div 256 # cover edges and more
for i in countdown(128,1):
for j in [-4096, -64, -49, -48, -47, -32, 0, 4096]:
let b = n + j - i*d
if b>0 and b<=nmax:
test(b)
#echo b, ": ", getTotalMem(), " ", getOccupiedMem(), " ", getFreeMem()
# allocator adds 48 bytes to BigChunk
# BigChunk allocator edges at 2^n * (1 - s) for s = [1..32]/64
proc test2(n: int) =
let d = n div 256 # cover edges and more
for i in countdown(128,1):
for j in [-4096, -64, -49, -48, -47, -32, 0, 4096]:
let b = n + j - i*d
if b>0 and b<=nmax:
test(b)
#echo b, ": ", getTotalMem(), " ", getOccupiedMem(), " ", getFreeMem()
proc test3 =
var n = 1
while n <= nmax:
test2(n)
n *= 2
n = nmax
while n >= 1:
test2(n)
n = n div 2
proc test3 =
var n = 1
while n <= nmax:
test2(n)
n *= 2
n = nmax
while n >= 1:
test2(n)
n = n div 2
test3()
test3()

View file

@ -1,6 +1,5 @@
discard """
output: '''abc
16 == 16'''
output: '''abc'''
"""
type
@ -14,20 +13,3 @@ a.x = "abc"
doAssert TA.sizeof == string.sizeof
echo a.x
##########################################
# bug #9794
##########################################
type
imported_double {.importc: "double".} = object
Pod = object
v* : imported_double
seed*: int32
Pod2 = tuple[v: imported_double, seed: int32]
proc test() =
echo sizeof(Pod), " == ",sizeof(Pod2)
test()

View file

@ -40,6 +40,11 @@ static:
let a2 = arcsin 0.3
doAssert a1 == a2
block bitxor:
let x = -1'i32
let y = 1'i32
doAssert (x xor y) == -2
block:
# Check against bugs like #9176
doAssert getCurrentCompilerExe() == forceConst(getCurrentCompilerExe())

View file

@ -13,14 +13,14 @@ proc get_values(): (seq[int8], seq[int16], seq[int32]) =
result[0] = @[]; result[1] = @[]; result[2] = @[]
for offset in RANGE:
let i8 = -(1 shl 9) + offset
let i16 = -(1 shl 17) + offset
let i32 = -(1 shl 33) + offset
let i8 = -(1'i64 shl 9) + offset
let i16 = -(1'i64 shl 17) + offset
let i32 = -(1'i64 shl 33) + offset
# higher bits are masked. these should be exactly equal to offset.
result[0].add i8.toU8
result[1].add i16.toU16
result[2].add i32.toU32
result[0].add cast[int8 ](uint8 cast[uint64](i8 ))
result[1].add cast[int16](uint16 cast[uint64](i16))
result[2].add cast[int32](uint32 cast[uint64](i32))
# these values this computed by VM