Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2025-05-14
12:04 • Ticket [b7834045b9] MS-VC 6 on core-8-6-branch: compile error C2520: conversion ... artifact: 21ca13c662 user: jan.nijtmans
11:29 • Ticket [b7834045b9]: 6 changes artifact: d208780e78 user: oehhar
09:21 • Closed ticket [b7834045b9]. artifact: 9856d4705a user: jan.nijtmans
2025-05-13
14:32 • Ticket [b7834045b9]: 3 changes artifact: 0f51ae3259 user: chw
14:23 • Ticket [b7834045b9]: 3 changes artifact: 887c4595bc user: chw
10:38 • Ticket [b7834045b9]: 3 changes artifact: 6c3357adbc user: jan.nijtmans
09:06 • Ticket [b7834045b9]: 3 changes artifact: 3c0ece4766 user: dkf
2025-05-05
16:07 • Ticket [b7834045b9]: 4 changes artifact: 1ddd5dd92f user: oehhar
15:37
Fix [b7834045b9]: MS-VC 6 on core-8-6-branch: compile error C2520: conversion from unsigned __int64 ... check-in: ead995eddf user: jan.nijtmans tags: core-8-6-branch
14:24 • Ticket [b7834045b9] MS-VC 6 on core-8-6-branch: compile error C2520: conversion ... artifact: 02d62c0ffa user: oehhar
14:23 • New ticket [b7834045b9]. artifact: f0d8e57306 user: oehhar

MS-VC 6 on core-8-6-branch: compile error C2520: conversion from unsigned __int64 to double not implemented, use signed __int64

Closed / Fixedb7834045b9126bb6aa3457ea6b2be32c080e759fCreated 2 years agoUpdated 2 years ago
Descriptionwiki2025-05-05 14:23:26
I tried today to compile the branch core-8-6-branch with MS-VC6++ in 32 bit mode. I got the following error messages:
generic\tclStrToD.c(1669) : error C2520: conversion from unsigned __int64 to double not implemented, use signed __int64
generic\tclStrToD.c(1683) : error C2520: conversion from unsigned __int64 to double not implemented, use signed __int64
generic\tclStrToD.c(1697) : error C2520: conversion from unsigned __int64 to double not implemented, use signed __int64

The compiler can not do:

Tcl_WideUInt significand;
(double)significand

Checkout:

checkout:     ad842e3313634f598b29ac58494b5b7bd1c85c67 2025-04-16 17:34:13 UTC
parent:       87abac372cb137f79032e7bd022a48e6f7bbf31e 2025-04-15 12:00:56 UTC
tags:         core-8-6-branch

I am only reporting. It is ok to not support this compiler. But in the past, we did.

Thanks for all, Harald

Referenced by1
  • ead995eddfFix [b7834045b9]: MS-VC 6 on core-8-6-branch: compile error C2520: conversion from unsigned __int64 to double not implemented, use signed __int64 No need to put it in change log, because regression was caused by [4128866276b86868] check-in2025-05-05 15:37:13
oehhar Ticket [b7834045b9]: 3 changes [History diff]2025-05-05 14:24:30
oehharwiki2025-05-05 16:07:19

Jan, thanks for the fix.

I tested on MS-VC 6 32 bit:

==== scan-15.1 scan %g overflow for small numbers and big mantissa bug 42d14c495a FAILED
==== Contents of test case:

    set result [list]
    # xfail: n<num> = not expected at all, x<num> expected when unfixed
    foreach {exp numdig ret xfail} {
        -321  190 1.111647703142804724397279783953498087821e-321 n0
        -321  191 1.111647703142804724397279783953498087821e-321 x1
        -321  300 1.111647703142804724397279783953498087821e-321 x2
        -321 1600 1.111647703142804724397279783953498087821e-321 x3
        -400  110 0 n4
        -400  111 0 n5
        -400  300 0 n6
        -221  290 1.111111111111110993454921768172890541494e-221 n7
        -221  291 1.111111111111110993454921768172890541494e-221 x8
        -221  400 1.111111111111110993454921768172890541494e-221 x9
        -221 1600 1.111111111111110993454921768172890541494e-221 x10
        -121  390 1.111111111111111182884141698869046969295e-121 n11
        -121  391 1.111111111111111182884141698869046969295e-121 x12
        -121  500 1.111111111111111182884141698869046969295e-121 x13
        -121 1600 1.111111111111111182884141698869046969295e-121 x14
         308  202 1.111111111111111167662077577927612945036e+308 n15
         308  203 1.111111111111111167662077577927612945036e+308 n16
         308  300 1.111111111111111167662077577927612945036e+308 n17
         308 1600 1.111111111111111167662077577927612945036e+308 x18
         400  110 inf n19
         400  111 inf n20
         400  300 inf n21
         221  291 1.111111111111111207481621395250718679869e+221 n22
         221  292 1.111111111111111207481621395250718679869e+221 n23
         221  400 1.111111111111111207481621395250718679869e+221 n24
         221 1600 1.111111111111111207481621395250718679869e+221 x25
         121  391 1.11111111111111112711771954138363761759e+121 n26
         121  392 1.11111111111111112711771954138363761759e+121 n27
         121  500 1.11111111111111112711771954138363761759e+121 n28
         121 1600 1.11111111111111112711771954138363761759e+121 x29
    } {
        set s 1.[string repeat 1 $numdig]e$exp
        set d "no_scan"
        scan $s %g d
        set r [format %.40g $d]
        if {$r ne $ret} {
            lappend result $xfail=[format %.40g $d]
        }
    }
    set result

---- Result was:
n0=1.1116477031428047e-321 x1=1.1116477031428047e-321 x2=1.1116477031428047e-321 x3=1.1116477031428047e-321 n7=1.111111111111111e-221 x8=1.111111111111111e-221 x9=1.111111111111111e-221 x10=1.111111111111111e-221 n11=1.1111111111111112e-121 x12=1.1111111111111112e-121 x13=1.1111111111111112e-121 x14=1.1111111111111112e-121 n15=1.1111111111111112e+308 n16=1.1111111111111112e+308 n17=1.1111111111111112e+308 x18=1.1111111111111112e+308 n19=1.#INF n20=1.#INF n21=1.#INF n22=1.1111111111111112e+221 n23=1.1111111111111112e+221 n24=1.1111111111111112e+221 x25=1.1111111111111112e+221 n26=1.1111111111111111e+121 n27=1.1111111111111111e+121 n28=1.1111111111111111e+121 x29=1.1111111111111111e+121
---- Result should have been (exact matching):

==== scan-15.1 FAILED

It does not fail with MS-VS 2022 on 64 bit. There, all is still ok.

We may accept this failure as platform specific.

Nevertheless, to cast this for all compilers on core-8-6-branch scares me a bit...

Thanks for all, Harald

dkfmarkdown2025-05-13 09:06:46

Also failing in CI on Windows (this is from the core-9-0-branch tip) with gcc.

---- Result was:
n0=1.1116477031428047e-321 x1=1.1116477031428047e-321 x2=1.1116477031428047e-321 x3=1.1116477031428047e-321 n7=1.111111111111111e-221 x8=1.111111111111111e-221 x9=1.111111111111111e-221 x10=1.111111111111111e-221 n11=1.1111111111111112e-121 x12=1.1111111111111112e-121 x13=1.1111111111111112e-121 x14=1.1111111111111112e-121 n15=1.1111111111111112e+308 n16=1.1111111111111112e+308 n17=1.1111111111111112e+308 x18=1.1111111111111112e+308 n19=1.#INF n20=1.#INF n21=1.#INF n22=1.1111111111111112e+221 n23=1.1111111111111112e+221 n24=1.1111111111111112e+221 x25=1.1111111111111112e+221 n26=1.1111111111111111e+121 n27=1.1111111111111111e+121 n28=1.1111111111111111e+121 x29=1.1111111111111111e+121
---- Result should have been (exact matching):

It looks suspiciously like this might be a bug with the particular libc, which opts to truncate the number of digits in this case.

jan.nijtmanswiki2025-05-13 10:38:42

Let's see how [this] works better

chwplain2025-05-13 14:23:30
My admittedly limited understanding of Tcl's format command is
that it does not depend on the C library w.r.t. sprintf(…%g…).
This was the reason I've chosen %.40g in my proposed test.
So there must some other thing be fishy in the code.
chwplain2025-05-13 14:32:22
Turns out I was wrong, there's a magic

  sprintf(bytes, spec, d)

which does the heavy lifting using the C library.

Makes me wonder how much effort we've spent on
scanning compared to this solution.
jan.nijtmanswiki2025-05-14 09:21:04

I 'fixed' the last 3 lines in the testcase which was still failing: Not all C runtimes spit out "inf" for Inf.

Closing

oehharwiki2025-05-14 11:29:11

Great, thank you.

Out of curiosity, what do others return? "-Inf" ?

Would it be reasonable to compare with [expr {isinf($f)}] or tcl::mathfunc::isinf $f ?

Thanks for all, Harald

jan.nijtmansplain2025-05-14 12:04:06
> Out of curiosity, what do others return? "-Inf" ?

GCC included with Mingw-W64 (the version used in Github CI) returns "1.#INF".

>Would it be reasonable to compare with [expr {isinf($f)}] or tcl::mathfunc::isinf $f ?

That wouldn't work. "expr" doesn't know what to do with "1.#INF" ;-)

I suspect this is a temporary problem. If modern C runtimes just return "inf", everything is OK. Not worth to spend more time on it.
Log in (anonymous is fine) to add a comment.