-
Notifications
You must be signed in to change notification settings - Fork 168
Open
Description
Example code:
void test_case(float arr[], size_t len)
{
for (int i = 0; i < len; i++) {
printf("%f\n", arr[i]);
}
char *json = json_asprintf("{state:{reported:{temps:%M}}}",
json_printf_array, arr, len * sizeof(arr[0]),
sizeof(arr[0]), "%f");
if (json) {
printf("%s\n", json);
free(json);
}
}
int main(int argc, char *argv[])
{
float arr[3] = {
1.1,
2.2,
3.3
};
test_case(arr, 3);
return 0;
}
The printf of the loop is correct. The correct number of elements are added to the json, but they are all zero. This is being compiled for the esp32 with xtensa-esp32-elf-gcc (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a) 5.2.0
I've copied the elements to an array of double using "%lf" and this is a workaround for the problem.
Edit: Added a main and tested on amd64 as well, and repro'd there too. I was worried this might be due to the esp32 hardware float lazy context switch.
Metadata
Metadata
Assignees
Labels
No labels