Operating System - HP-UX
1833083 Members
4019 Online
110050 Solutions
New Discussion

compilation fails on Pa-risc2 but succeeds on ia64

 
SOLVED
Go to solution
Manish_33
Advisor

compilation fails on Pa-risc2 but succeeds on ia64

Hi all,
I have a piece of code , the compilation of which fails on two different platforms.

1)$uname -a
HP-UX tivsc161 B.11.23 U 9000/785 2000950800 unlimited-user license

$cc +DD64 test1.c
cc: "test1.c", 34: 1653: , line : error : Case label too big for the type of the switch expression

Compiler details :
cpp.ansi: HP92453-01 B.11.11.10 HP C Preprocessor (ANSI)
ccom: HP92453-01 B.11.11.02 HP C Compiler


While on Itanium 11.23 :
2)uname -a
HP-UX tivsec15 B.11.23 U ia64 3018900438 unlimited-user license
The version of compiler is :
cc: HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]
The code compiles without errors:
cics#iadce1#/home/cics/omar>
$cc +DD64 test1.c
cics#iadce1#/home/cics/omar>

The piece of code in question is:
#include
#include

#define test (-1765328347L)

int main()
{

unsigned int a=1;
switch(a)
{
case test:printf("In switch case\n");
default: printf("In default\n");
;
}
}


Why is it so ? It compiles on Itanium while fails on PARISC when a is declared as "unsigned int" . Shouldn't it fail on both the platforms ? ..... Is there any missing compiler flag or any flag which i can add on PARISC and made the code to compile ?

Thanks in advance
3 REPLIES 3
Dennis Handly
Acclaimed Contributor

Re: compilation fails on Pa-risc2 but succeeds on ia64

You are dealing with two different compilers.

>any flag which i can add on PA-RISC and made the code to compile?

If you want it to compile you should cast the case label to unsigned int. Or cast "a" to a long.

I'll have to check the Standard about the promotion rules for case labels vs the switch variable.

Note the Integrity compiler you have, A.05.55, is obsolete and not supported. The latest version is A.06.14.
TY 007
Honored Contributor

Re: compilation fails on Pa-risc2 but succeeds on ia64

Hi,

>> Compiler details :
>> cpp.ansi: HP92453-01 B.11.11.10 HP C Preprocessor (ANSI)
>> ccom: HP92453-01 B.11.11.02 HP C Compiler

Load in these OS Patches if applicable:
PHSS_28435 linker startup code / SLLIC ELF support
PHSS_34880 LIBCL patch
PHSS_35175 HP C Preprocessor B.11.11.16 cumulative patch
PHSS_35383 ld(1) and linker tools cumulative patch
PHSS_36086 ANSI C compiler B.11.11.16 cumulative patch
PHSS_36088 +O4/PBO Compiler B.11.11.16 cumulative patch

Perform the compilation again.

Thanks
Dennis Handly
Acclaimed Contributor
Solution

Re: compilation fails on Pa-risc2 but succeeds on ia64

>Shaolin: Load in these OS Patches if applicable: ...

These won't help. This is a bug in the PA compiler. You need to contact the Response Center.

The Integrity compiler meets the C++ and C99 Standards where each case label is implicitly converted to the promoted type of the switch condition.

Though in your case, your negative long will be converted to an unsigned int. This is a maintenance nightmare waiting to happen.