|
-----Original Message----- From: rpg400-l-admin@midrange.com [mailto:rpg400-l-admin@midrange.com]On Behalf Of Barbara Morris >Well, it's not by explicit intent of RPG. We don't generate any special >code to get this behaviour. Hi Barbara, It seems pretty odd to me that a *Null pointer can be added to without an exception being returned. First of all, in MI a null pointer cannot be added to. Shouldnt the AS400 behave consistently, esp since the underlying pointers are the same? Also, the offset of a pointer can be used as data. Subtracting one pointer from another returns a decimal difference in RPG. Consider that a pointer can be stored in a permanent user space. One job could add to the pointer and another job could use the resulting pointer. So the add to the pointer is not a superfluous operation. >I don't know if that makes it a bug though. It may be that pointer >arithmetic is done just on the 16-byte variable itself, without the >check for pointerness, for performance reasons, leaving the >pointer-check for later when the pointer is dereferenced. Adding too much to a pointer will cause an exception. So there is checking of the pointer at "add to the pointer" time. The following code causes an MCH0601 exception. d ActualData s 256a d pBegin s * d pData s * d nDiff s 10i 0 c eval pBegin = %addr(ActualData) c eval pData = pBegin c do 1000000 c eval pData = pData + 32 c eval nDiff = pData - pBase c enddo Steve Richter
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.