Well, I am not the C standard, but you can find it online. <g>

I believe nullptr is numerically equal to zero, but it is a pointer type. It
is perhaps equivalent to (void *)0

It is specifically not an integer, unlike NULL, which is another name for
the integer zero.

<Untested>

int foo = NULL;  // compiles
int bar = nullptr;  // generates an error 
void *sojack = nullptr;   // compiles

Charles


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On
Behalf Of Seymour J Metz
Sent: Tuesday, March 1, 2022 10:09 AM
To: [email protected]
Subject: Re: ZAD and C/C++ (was:: 2.5 Heads Up)

Is nullptr an address of 0, or is it an address guarantied to not be valid?

"An integer constant expression with the value 0, or such an expression cast
to type void *, is called a null pointer constant. If a null pointer
constant is converted to a pointer type, the resulting pointer, called a
null pointer, is guaranteed to compare unequal to a pointer to any object or
function."


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3

________________________________________
From: IBM Mainframe Discussion List [[email protected]] on behalf of
Charles Mills [[email protected]]
Sent: Tuesday, March 1, 2022 11:46 AM
To: [email protected]
Subject: Re: ZAD and C/C++ (was:: 2.5 Heads Up)

C is a standardized language. IBM's main target market is programs ported
from other platforms. I have no idea what the standard is, but IBM *may*
simply be following it. fopen(NULL, ...) is pretty useless any way you slice
it.

I have no idea what (void I)"" would mean and I don't *think* it is valid C.
A quick test of auto foo = (void I)""; gives me a bunch of errors.

NULL is nothing special in C: it is just an alias for 0 (zero). That lead to
a somewhat astonishing behavior in a particular situation involving
overloaded functions, and the new (C++ only? Perhaps C also) language
standards include nullptr, which is specifically an *address* of zero, and
is a better usage than NULL if the meaning is "the address of nothing." That
is, "you are expecting me to pass you an address and I am telling you that I
have no address to give you."

Charles


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On
Behalf Of Paul Gilmartin
Sent: Tuesday, March 1, 2022 8:30 AM
To: [email protected]
Subject: ZAD and C/C++ (was:: 2.5 Heads Up)

On Tue, 1 Mar 2022 13:28:01 +0000,  wrote:
><snip>
>ZAD is not supported on z/OS under z/VM. "    :-(
>Is there any SOD or RFE or the like for this?
></snip>
>
Many releases ago, I saw a report the C RTL treatment of following a
NULL pointer was changing.  I tested open( NULL, ... ) with releases
before and after the change.  The earlier reported Invalid Pointer; the
later Invalid Filename.  I considered the earlier more precise and
correct.  I conjecture that IBM had fecklessly accommodated
programmers accustomed to misusing NULL instead of e.g. (void I)"".

There are probably still programs that follow null pointers. What will
become of them?

I favor strict error reporting.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to