This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Missing newline in strings passed to printf

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

Any ideas or thoughts?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]