Skip to content

Libm: the NAN define is likely broken for VBCC #12

@dplanitzer

Description

@dplanitzer

Describe the bug
Libm currently defines NAN as

#define NAN ((float)(INFINITY * 0.0f))

when it should actually be

#define NAN (0.0f/0.0f)

It isn't defined like this because of the incorrect-flush-to-zero bug in VBCC described in another ticket. The multiply-by-zero however likely doesn't produce a nan either.

To Reproduce
Write code that uses the NAN define

Expected behavior
Should produce a type correct NAN (float, double, long double).

OS (please complete the following information):

  • Version 0.7.0-alpha

Additional context
Keep in mind that the NAN define can not depend on a global variable. Libc expects that it can #include<math.h> and use the NAN and INFINITY defines without having to actually link in libm.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions