View previous topic :: View next topic
|
Author |
Message |
CICS fan
New User
Joined: 03 Apr 2008 Posts: 82 Location: United States
|
|
|
|
Hello All,
I am getting the following compilation error while compiling a PLI code
IBM2402I Evariable name 1 declared as BASED on the ADDR of variable name 2, but variable name 1 requires more storage than variable name 2.
Is there any compiler option available to workaround this beacuse this is an existing code.
Thanks in advance. |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
This is an informatory message which "shouldn't" affect execution. The compiler's just warning you of a potential for storage violation. Older compilers didn't detect this potential cause of runtime error.
If you assign something into Variable-1 at a point beyond the end of Variable-2 you are effectively in uncharted waters. If something else is validly occupying that memory location, you run the risk of overwriting it.
The proper approach is the change the declarations such that Variable-2 is BASED on the ADDR of Variable-1.
Garry. |
|
Back to top |
|
|
CICS fan
New User
Joined: 03 Apr 2008 Posts: 82 Location: United States
|
|
|
|
Thank you Garry, but the compiler is issuing an error wth return code 12. It is not a warning! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
It may help if you post the variables and the code that references the variables along with the diagnostic messsages from the compiler. |
|
Back to top |
|
|
CICS fan
New User
Joined: 03 Apr 2008 Posts: 82 Location: United States
|
|
|
|
we are facing the following error:
MIR_REC_OVERLAY is declared as BASED on the ADDR of
IN_MIR, but MIR_REC_OVERLAY requires more storage than
IN_MIR.
This is an existing code. The error message gets eliminated if we declare Y after X, then
Y declared as BASED(ADDR(X)).
For example,
Current code:
0DCL 1 IN_MIR STATIC UNALIGNED,
%INCLUDE HANIMAN;
%INCLUDE HANIEXT;
%INCLUDE HANIMIR;
3 DUMMY CHAR(0);
0DCL MIR_REC_OVERLAY CHAR(70) BASED(ADDR(IN_MIR));
Changed code:
0DCL MIR_REC_OVERLAY CHAR(70) STATIC UNALIGNED;
0DCL 1 IN_MIR BASED(ADDR(MIR_REC_OVERLAY)), /* INPUT FILE ISBIMIR */
%INCLUDE HANIMAN;
%INCLUDE HANIEXT;
%INCLUDE HANIMIR;
3 DUMMY CHAR(0); /* END OF INPUT */
Is there a work around this problem, like compiler options etc or modifying processor group definations? Please advise. |
|
Back to top |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
This message alerts you to a potentially important coding error: IBM2402I E <variable x> is declared as BASED on the ADDR of <variable y>, but <variable x> requires more storage tha <variable y>.
The importance of this message depends on how the variables are used in your program. For instance, if X is a 100-byte structure and Y is declared as CHAR(200) BASED(ADDR(X)), then the compiler will issue this message. If your program also contains the statement Y = ’’, then you have a severe problem (because that assignment will wipe out 100 bytes of storage that the compiler is likely to be using for other purposes). You must correct this kind of problem.
However, your program might use Y only in the statements such as: SUBSTR(Y,1,STG(X)) = ’’;
SUBSTR(Y,1,STG(X)) = LOW(STG(X));
In this case, your code does not need to be changed.
However, in this case, you could change the declare of Y to eliminate these messages: if you declare Y after X, you could then declare Y as CHAR(STG(X)) BASED(ADDR(X)). This would eliminate this occurrence of the message without your having to make any changes to your code. But, if you wanted, you could also then simplify the above assignment statements to:
Y = ’’;
Y = LOW(STG(X)); |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
In any case, as I said:
The proper approach is the change the declarations such that Variable-2 is BASED on the ADDR of Variable-1. |
|
Back to top |
|
|
fahir83
New User
Joined: 27 Jan 2006 Posts: 22
|
|
|
|
I got the same error while upgradring to Enterprise PL/1:
Following is the error:
IBM2402I E O_RPT is declared as BASED on the ADDR of O_RPT_OVLY, but O_RPT requires more storage than O_RPT_OVLY
and here is the declaration.
DCL O_RPT_OVLY CHAR(128) INIT(' ');
DCL 01 O_RPT BASED(ADDR(O_RPT_OVLY)),
++INCLUDE SGHASCAC
SGHASCAC:
05 BRANCH CHAR(03),
05 PDN CHAR(05),
05 ACT_NBR CHAR(03),
05 NAME CHAR(30),
05 TXN_NBR CHAR(15),
05 TXN_TYP CHAR(10),
05 ACH_TXN_NBR PIC '(15)9',
05 TRACE_NBR CHAR (30),
05 DB_CR_IND CHAR(02),
05 AMT PIC '(13)9V.99';
I have just changed the O_RPT_OVLY declaration to CHAR(129). It compiled without any issues. But the question is how it compiled succesfully in old compiler (pl/1 for mvs) ?i didnt even get the warning message.
and anyone let me know whether changing the size is the best option or whether i need to do something else? |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Quote: |
anyone let me know whether changing the size is the best option or whether i need to do something else? |
Quote: |
as I said:
The proper approach is the change the declarations such that Variable-2 is BASED on the ADDR of Variable-1. |
The reason you didn't get the error in earlier compilers is that the compiler didn't check these lengths. As compilers mature, they are getting stricter on syntax and do more detailed checking.
Increasing the size of the shorter variable is not the best option, though it will remove the error message and should prevent the potential destructive overlay. If there is a reason for having two structures defined at he same storage offset, it is better to have the largest such as static or automatic with the short structures overlaid on it.
The purpose of the overlay may affect the choice of which option to go for. In this case, it looks like O_RPT_OVLY CHAR might be used to clear/blank the structure, in which case both definitions should be the same length.
Garry. |
|
Back to top |
|
|
laurie pach
New User
Joined: 29 Oct 2007 Posts: 1 Location: victoria, bc, canada
|
|
|
|
I just want you all to know I applied your 2 solutions and I'm home free!! To summarize:
1. Yes, Gurgaon, make sure that the 'BASED on ADDR' declaration comes first.
2. Yes, Gary, make sure the sizes of both declarations are the SAME!!
And yes, I know you were all throwing this issue around over a year and a half ago, but I want you to know you have all been a tremendous help to me. THANK YOU SO MUCH!! Laurie |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
Garry Carroll wrote: |
Quote: |
anyone let me know whether changing the size is the best option or whether i need to do something else? |
Quote: |
as I said:
The proper approach is the change the declarations such that Variable-2 is BASED on the ADDR of Variable-1. |
|
No, the best approach using Enterprise PL/I is to use UNION, it will generate better code and the structure will automatically take on the size of the largest variable making up the UNION.
Garry Carroll wrote: |
The reason you didn't get the error in earlier compilers is that the compiler didn't check these lengths. As compilers mature, they are getting stricter on syntax and do more detailed checking. |
Which sadly means that this wonderful snippet of V2.3.0 PL/I can no longer be compiled with Enterprise PL/I...
Code: |
%dcl z%z='put edit';proc options(main;q=''''put list(m;do i=1,2;z(q)skip;do j=
1to 78c=substr(m(i),j;if c=q z(c;z(c;end;z(q',';dcl(c,q)char,m(2)char(99)init(
'%dcl z%z=''put edit'';proc options(main;q=''''''''put list(m;do i=1,2;z(q)skip;do j=',
'1to 78c=substr(m(i),j;if c=q z(c;z(c;end;z(q'','';dcl(c,q)char,m(2)char(99)init(', |
|
|
Back to top |
|
|
|