Skip to content

CBMC fails to type-check initialization of static variable of type float with value +INFINITY #8710

@andreast271

Description

@andreast271

If a static variable inside a function is initialized with +INFINITY, cbmc fails to typecheck the program.
Example program main.c:

#include <math.h>
void func() {
  static float f = +INFINITY;
}

CBMC command: cbmc main.c
Output:

CBMC version 6.7.1 (cbmc-6.7.1-dirty) 64-bit x86_64 linux
Type-checking main
file main.c line 3 function func: expected constant expression, but got '__builtin_inff()'
CONVERSION ERROR

The preprocessor replaces +INFINITY with __builtin_inff(). GCC allows initialization of a static variable with the return value of __builtin_inff(), CBMC does not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions