https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83557
--- Comment #3 from m68k <x37a5709 at gmail dot com> ---
Thanks for the feedback of this forgotten/unexpected behavior.
The funny part of this is, that the rules are not easy to adopt
see what printf("%c\r\n", 'A');
5 .LC1:
6 0002 25630D0A .string "%c\r\n" <--printf("%c\r\n", 'A');
6 00
HERE \n is maintained, not taking into account puts behavior!!
\n is also maintained in some semantic wrong but syntax correct statement
see and compare:
printf("\r\n"); with printf("\r\n", ' ');
3 .LC0:
4 0000 0D00 .string "\r" <---printf("\r\n");
5 .LC1:
6 0002 0D0A00 .string "\r\n" <---printf("\r\n", ' ');
and \n is also maintained when \n not at the end of a string
see what printf("\n\r"); brings
11 .LC4:
12 000d 0A0D00 .string "\n\r" <---printf("\n\r)");
On 12/22/2017 04:57 PM, pinskia at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83557
>
> Andrew Pinski <pinskia at gcc dot gnu.org> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> Status|UNCONFIRMED |RESOLVED
> Resolution|--- |INVALID
>
> --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
> printf("\r\n");
>
> Gets converted into puts("\r"); as allowed by the C standard. The C standard
> says \n is a new line and puts will put a newline marker on the stdout.
>
> If you don't want this conversion use -fno-builtins, -fno-builtin-printf,
> -ffree-standing (I think that is the option name).
>