Fossil SCM

fossil-scm / test / long-double.test
Blame History Raw 72 lines
1
#
2
# OpenBSD on 64 bit SPARC has what appears to be a complier bug involving
3
# the "long double" type. This has been observed on OpenBSD 5.1 and 5.2
4
# using the bundled gcc compiler (gcc (GCC) 4.2.1 20070719).
5
#
6
# The following progam demonstrates the problem:
7
#
8
# #include <stdio.h>
9
#
10
# int
11
# main (int argc, char *argv[])
12
# {
13
# volatile long long n;
14
# volatile long double ld;
15
#
16
# n = 2147483648L;
17
# ld = n;
18
# printf (" n = %lld\n", n);
19
# printf ("ld = %0.17Lg\n", ld);
20
#
21
# return 0;
22
# }
23
#
24
# Example output, on an x86 system without the bug:
25
# n = 2147483648
26
# ld = 2147483648
27
#
28
# Example output, on an OpenBSD/sparc64 system with the bug:
29
# n = 2147483648
30
# ld = -2147483648
31
#
32
# The bug manifests itself in Fossil by way of a long double in
33
# SQLite's internal sqlite3AtoF() function.
34
#
35
# An example demonstrating the bug using Fossil:
36
#
37
# $ ./fossil new x.fossil
38
# $ ./fossil sqlite3 -R x.fossil
39
# sqlite> select 2456247.35094206;
40
# -2456247.35094206
41
# sqlite> .quit
42
#
43
# See also:
44
#
45
# [fossil-users] System problem leads to Fossil problem on OpenBSD/sparc64
46
# http://www.mail-archive.com/[email protected]/msg11144.html
47
#
48
49
# Fossil will write data on $HOME, running 'fossil new' here.
50
# We need not to clutter the $HOME of the test caller.
51
set env(HOME) [pwd]
52
53
fossil new rep.fossil
54
55
proc long-double {testname args} {
56
set i 1
57
foreach {sql result} $args {
58
set out [open test.sql w]
59
puts $out $sql
60
close $out
61
fossil sqlite3 -R rep.fossil < test.sql
62
test long-double-$testname.$i {$::RESULT eq $result}
63
incr i
64
}
65
}
66
67
# Returns "-2456247.35094206" on systems with the long double compiler bug.
68
long-double 100 "select 2456247.35094206;" "2456247.35094206"
69
70
file delete rep.fossil
71
file delete test.sql
72

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button