IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

PLI Compilation Error


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
CICS fan

New User


Joined: 03 Apr 2008
Posts: 82
Location: United States

PostPosted: Mon Apr 27, 2009 9:38 am
Reply with quote

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
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Mon Apr 27, 2009 9:06 pm
Reply with quote

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
View user's profile Send private message
CICS fan

New User


Joined: 03 Apr 2008
Posts: 82
Location: United States

PostPosted: Tue Apr 28, 2009 9:08 am
Reply with quote

Thank you Garry, but the compiler is issuing an error wth return code 12. It is not a warning!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Apr 28, 2009 9:23 am
Reply with quote

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
View user's profile Send private message
CICS fan

New User


Joined: 03 Apr 2008
Posts: 82
Location: United States

PostPosted: Tue Apr 28, 2009 9:52 am
Reply with quote

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
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Tue Apr 28, 2009 12:08 pm
Reply with quote

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
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Tue Apr 28, 2009 12:34 pm
Reply with quote

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
View user's profile Send private message
fahir83

New User


Joined: 27 Jan 2006
Posts: 22

PostPosted: Wed Jul 29, 2009 9:05 pm
Reply with quote

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
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Thu Jul 30, 2009 12:25 pm
Reply with quote

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
View user's profile Send private message
laurie pach

New User


Joined: 29 Oct 2007
Posts: 1
Location: victoria, bc, canada

PostPosted: Thu Oct 14, 2010 10:56 pm
Reply with quote

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
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Oct 14, 2010 11:23 pm
Reply with quote

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(',
icon_sad.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Error while running web tool kit REXX... CLIST & REXX 5
No new posts Getting Error while trying to establi... DB2 3
Search our Forums:

Back to Top