Missing newline in strings passed to printf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

I'm seeing a rather odd problem in a m68k toolchain I'm running. I'm
using GCC 4.1.1. The problem occurs in this code:

printf("Hello, world!\r\n");

If I look at the string that is actually generated in the objdump of the
output, I find that the last \n is stripped, leaving only a \r. I've
tried other equivalent scenarios, giving the following results:

const char* greeting = "Hello, world!\r\n"; printf(greeting); -> CORRECT
puts("Hello, world!\r\n") -> CORRECT
void doit(const char *s){printf(s);} doit("Hello!\r\n"); -> CORRECT
printf("Hello, world!\n") -> "Hello, world!" (no \n)
printf("\n") -> putchar(0x0a) -> CORRECT

I've only seen this problem in my m68k toolchain, the native gcc seems
to handle it just fine. I am running gcc with only the following
options: -mcpu32 -g, so I'm not sure that any optimizations would be
creeping in. I've verified that the preprocessor output still says
"\r\n" and that the assembler input says only "\r" so this is a compiler
issue.

Any ideas or thoughts?

Luke


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux