Skip to content

stage2: zig cc compiled powf randomly returns NaN on Windows #12517

@jagt

Description

@jagt

Zig Version

0.10.0-dev.3653+7152a58c1

Steps to Reproduce

#include <stdio.h>
#include <math.h>

int main() {
    printf("! %f\n", powf(1.389f, 100.0f + 0.1f));

    int acc = 0;
    for (float xx = 0.f; xx < 100.0f; xx += 0.1f)
    {
        float v = powf(1.389f, xx);
        printf("%f: %f\n", xx, v);
        if (acc++ > 3) break;
    }
 
    return 0;
}

Expected Behavior

With clang it's like this:

clang -g -o powtest.exe .\powtest.c
.\powtest.exe
! 192529106468864.000000
0.000000: 1.000000
0.100000: 1.033404
0.200000: 1.067924
0.300000: 1.103597
0.400000: 1.140462

Actual Behavior

zig cc -g -o powtest2.exe .\powtest.c
.\powtest2.exe
! nan
0.000000: 1.000000
0.100000: nan
0.200000: nan
0.300000: nan
0.400000: nan

Note that this is reproducible with the zig.exe from zig win dev kit

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavioros-windowsMicrosoft Windowszig ccZig as a drop-in C compiler feature

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions