S
Sion Roberts
While porting our application to HP/UX 11.23 Itanium, I came across
this situation where the compiler acts differently to any other UNIX
C/C++ compiler that I have come across in the last 10 years (including
other HP-UX platforms).
Consider the following code:
#include <stdio.h>
int main()
{
char *ptr = "AB";
char *ans;
ans = (*ptr++) ? ptr : "";
printf ("Answer is %s\n", ans);
return 0;
}
When running this, I would usually expect to see:
Answer is B
On Itanium it displays:
Answer is AB
There are a few HPUX compilers to choose from on this platform, but
they all behave in the same way. Compiler switches don't make any
difference. I am now using GCC, which works as I expect.
aCC on HPUX 11 PA-RISC also displays "AB".
Has anyone come across this before or confirm that the results I've
seen are invalid for ANSI C?
Sion.
this situation where the compiler acts differently to any other UNIX
C/C++ compiler that I have come across in the last 10 years (including
other HP-UX platforms).
Consider the following code:
#include <stdio.h>
int main()
{
char *ptr = "AB";
char *ans;
ans = (*ptr++) ? ptr : "";
printf ("Answer is %s\n", ans);
return 0;
}
When running this, I would usually expect to see:
Answer is B
On Itanium it displays:
Answer is AB
There are a few HPUX compilers to choose from on this platform, but
they all behave in the same way. Compiler switches don't make any
difference. I am now using GCC, which works as I expect.
aCC on HPUX 11 PA-RISC also displays "AB".
Has anyone come across this before or confirm that the results I've
seen are invalid for ANSI C?
Sion.