Skip to content

CONFIG_LOG2 fails for floating point output with warning and bad output #35051

@SwissKnife64

Description

@SwissKnife64

The following code results in compiler warnings and wrong output.
The warning request a "double value" as argument?

==== Code:
char strWithDouble[] = "2.718";
double doubleValue = strtod(strWithDouble, &endPtr);

sprintf( outputStr, "%f", doubleValue);
LOG_INF("double value as string from sprintf %s", outputStr);

LOG_INF("double value with format %%f %f", doubleValue);
LOG_INF("double value with format %%g %g", doubleValue);
LOG_INF("double value with format %%a %a", doubleValue);

==== Output:
[00:00:00.006,126] blinky_json: double value as string from sprintf 2.718000
[00:00:00.006,133] blinky_json: double value with format %f -1761758827172083000000000000000000000000000.000000
[00:00:00.006,137] blinky_json: double value with format %g -1.76176e+42
[00:00:00.006,142] blinky_json: double value with format %a -0x1.439580801013ep+140

==== CONFIG
CONFIG_LOG=y
CONFIG_LOG2_MODE_DEFERRED=y

CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y

CONFIG_CBPRINTF_FP_A_SUPPORT=y

Metadata

Metadata

Assignees

Labels

area: LoggingbugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions