https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120609
Bug ID: 120609 Summary: printf fails for a decimal type if variable is unmodified Product: gcc Version: 13.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: madams846 at hotmail dot com Target Milestone: --- Created attachment 61609 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61609&action=edit .i file Printing a decimal data type value that is unmodified fails. Printout fail -- and success with variable modifications -- is the same for Decimal32, Decimal64 and Decimal128. I discovered this bug in a larger program. I was preparing a test case to report another bug with decimal data type. Simple program decBugDemo.c : #include <stdio.h> int main() { _Decimal64 value1 = 2.0dd ; printf("\n %7.7De \n\n", value1 ); return 0 ; } compiled with "gcc decBugDemo.c -ldfp" prints out “%7.7De”. Same program with an operation: _Decimal64 value1= 2.0dd ; _Decimal64 value2= 2.0dd; value1 += value2; printf("\n %7.7De \n\n", value1 ); prints out "4.0000000e+00" with no optimization option or with "-O0", but again prints out “%7.7De” with any other optimization level -O123 or -Ofast. Same program with one variable global #include <stdio.h> _Decimal64 value2= 2.0dd ; int main() { _Decimal64 value1= 2.0dd ; value1 += value2; printf("\n %7.7De \n\n", value1 ); return 0 ; } prints out "4.0000000e+00" with any optimization level. My gcc version is (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 using WSL on Windows 11 Home 24H2 OS build 26100.4202 running on 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz .