Operating System - HP-UX
1751894 Members
5043 Online
108783 Solutions
New Discussion юеВ

Re: Which option can initialize variable in aCC compiler A.06.15?

 
zang_1
Advisor

Which option can initialize veriable in aCC comppiler 6.15?

I use aCC compiler to compile my application, I found no varible is initialized if I use option +O1(default), but if I use +O0(or +O2, +O3, +O4), the varibles are initialized.

I checked compiler documents, no any information about this, how can I know which option can initialize varibles?
5 REPLIES 5
zang_1
Advisor

Re: Which option can initialize veriable in aCC comppiler 6.15?

I use HP-UX 11i v3 on rx3600.
Dennis Handly
Acclaimed Contributor

Re: Which option can initialize variable in aCC compiler A.06.15?

You must initialize your variables by initialization or assignment expressions or by default constructors.

If you get these warnings:
warning 20035: variable "%s" is used before its value is set
warning 2549: variable "%s" is used before its value is set

The optimizer may set the register to 0 to prevent worse problems.
The optimizer may set more registers to 0 if you use +Oinitcheck.
warning 20037: variable "%s" may be used before its value is set

In any case, you should NOT depend on this. Instead you should initialize the variables mentioned in the warnings.

zang_1
Advisor

Re: Which option can initialize veriable in aCC comppiler 6.15?

Do you mean there is no any option that can automatic initialize local varibles?
Because I need to port very old source from 11.0 to 11i v3.

The problem is all local varibles are initialized in old OS, but in new OS no any varible is initialized, it is impossible to add initialization code for all sources.

This is why I hope there is a option for initialization automatically.
Dennis Handly
Acclaimed Contributor

Re: Which option can initialize variable in aCC compiler A.06.15?

>Do you mean there is no option that can automatically initialize local variables?

That's correct.

>The problem is all local variables are initialized in old OS, but in new OS no variable is initialized

What OS and hardware were you using before?

>it is impossible to add initialization code for all sources.

Well you can make these warnings into errors so you have to initialize them:
+We20035,2549,20037

Dennis Handly
Acclaimed Contributor

Re: Which option can initialize variable in aCC compiler A.06.15?

>port very old source from 11.00 to 11i v3.

Neither this compiler nor the OS would zero out local variables. Why do you think you have more of a problem on your IPF port?

(The PA32 dld may have zeroed out some initial portion of the stack but not everything.)