Skip to content

Incorrect global/static float array initialization #315

@fourcolor

Description

@fourcolor

The following code run through rv32emu did not function as expected. I have also tested it with spike, confirming that the issue is specific to rv32emu. This error will lead to an error when running #28 embench-iot minver

  • global static float array initialization
#include <stdio.h>
static float test[3] = {-3.0, 0.0, 2.0};
int main()
{
    printf("%f\n", test[0]);
    return 0;
}

compile

riscv32-unknown-elf-gcc test.c -march=rv32imafc -mabi=ilp32 -o test.elf

expect output

-3.000000
inferior exit code 0

actual output

0.000000
inferior exit code 0

Furthermore, I have observed that the same issue exists in the following code.

  • global float array initialization
#include <stdio.h>
float test[3] = {-3.0, 0.0, 2.0};
int main()
{
    printf("%f\n", test[0]);
    return 0;
}
  • local static float array initialization
#include <stdio.h>
int main()
{
    static float test[3] = {-3.0, 0.0, 2.0};
    printf("%f\n", test[0]);
    return 0;
}

I notice that it only occurred with the global float array initialization and static float array initialization

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions