NULL不为零的机器的引用。 [英] References for machines where NULL is not zero.

查看:84
本文介绍了NULL不为零的机器的引用。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



您好。


我一直在阅读关于NULL与零的过去讨论。

参考文献总是使用值而不是零的系统或机器来代表NULL指针。


虽然不是我遵循的做法,但毫无疑问数百万行

开源库和应用程序执行以下操作:


p = malloc(...);

如果(!p)

失败。


这对非零NULL机器来说显然是一件坏事。


任何人都可以提供现代机器/系统的具体示例

它们是嵌入式还是超级计算机,其中NULL不为零?


标准说标准说的是什么而且我不想辩论它。

相反,我想找到反例来证明标准的'

语言仍然相关。 />

谢谢,

保罗。


Hello.

I''ve been reading some past discussions on the NULL vs. zero.
References are always made to systems or machienes that use values
other than zero to represent the NULL pointer.

Although not a practice I follow, there are no doubt millions of lines
of open source libraries and applications that do things like:

p = malloc(...);
if (!p)
fail.

Which is obviously a bad thing on non-zero NULL machines.

Can anybody provide specific examples of modern machines/systems be
them embedded or supercomputer where NULL is not zero?

The standard says what the standard says and I don''t want to debate it.
Rather, I want to find counter-examples to prove that the standard''s
language still relevant.

Thanks,
Paul.

推荐答案

pm***@yahoo.com 写道:
你好。

我一直在阅读过去关于NULL与零的讨论。
对于使用除零以外的值的系统或机器人的引用总是用来表示NULL指针。

虽然不是我遵循的做法,但毫无疑问数百万行的开源库和应用程序可以执行以下操作:

p = malloc (...);
如果(!p)
失败。

对于非零NULL机器来说,这显然是一件坏事。

一点都不。无论给定机器上的空指针

的实际位表示如何,上述方法都有效。
Hello.

I''ve been reading some past discussions on the NULL vs. zero.
References are always made to systems or machienes that use values
other than zero to represent the NULL pointer.

Although not a practice I follow, there are no doubt millions of lines
of open source libraries and applications that do things like:

p = malloc(...);
if (!p)
fail.

Which is obviously a bad thing on non-zero NULL machines.
No, not at all. Whatever the actual bit representation of a null pointer
on a given machine, the above works.



HTH,

- ag b / b
Artie Gold - 德克萨斯州奥斯汀
http://goldsays.blogspot.com (新帖子8/5)
http://www.cafepress.com/goldsays

如果你没有什么可隐瞒的,你就不会尝试! br />


HTH,
--ag
--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com (new post 8/5)
http://www.cafepress.com/goldsays
"If you have nothing to hide, you''re not trying!"


>我一直在阅读关于NULL与零的过去讨论。
>I''ve been reading some past discussions on the NULL vs. zero.
总是对使用的系统或机器人进行参考除了零以表示NULL指针之外的值。

虽然不是我遵循的实践,但毫无疑问数百万行的开源库和应用程序可以做类似的事情。 :

p = malloc(...);
如果(!p)
失败。

在非零NULL机器上显然是一件坏事。


不,这不是*显然是一件坏事。它应该工作正常,*即使在机器上的
,其中NULL不是全位零 - *。这可能会产生

机器代码:


cmpl r7,#0xdeadbeef

jne .L134

...失败的代码...

..L134:

请注意,即使在32位机器上,NULL的表示也是

* NOT *保证是0xdeadbeef,在64位机器上,NULL的

表示为* NOT *保证为0xdeadbeefdeadbeef。

任何人都可以提供现代机器/系统的具体示例




标准说标准说什么,我不想辩论它。
相反,我想找到反例证明标准'
语言仍然相关。
References are always made to systems or machienes that use values
other than zero to represent the NULL pointer.

Although not a practice I follow, there are no doubt millions of lines
of open source libraries and applications that do things like:

p = malloc(...);
if (!p)
fail.

Which is obviously a bad thing on non-zero NULL machines.
No, it is *NOT* obviously a bad thing. It should work fine, *EVEN
ON MACHINES WHERE NULL IS NOT all-bits-zero*. This might generate
the machine code:

cmpl r7,#0xdeadbeef
jne .L134
... code for "fail" ...
..L134:
Note that even on 32-bit machines, the representation of NULL is
*NOT* guaranteed to be 0xdeadbeef, and on 64-bit machines, the
representation of NULL is *NOT* guaranteed to be 0xdeadbeefdeadbeef.
Can anybody provide specific examples of modern machines/systems be
them embedded or supercomputer where NULL is not zero?

The standard says what the standard says and I don''t want to debate it.
Rather, I want to find counter-examples to prove that the standard''s
language still relevant.




Gordon L. Burditt



Gordon L. Burditt

在文章< 11 ********************** @ g43g2000cwa.googlegroups .com>

< pm * **@yahoo.com>写道:
In article <11**********************@g43g2000cwa.googlegroups .com>
<pm***@yahoo.com> wrote:
引用始终是使用除零以外的值来表示NULL指针的系统或机器人。


(总是?)

虽然不是我遵循的做法,但毫无疑问有数百万行开源库和应用程序执行以下操作:

p = malloc(...);
如果(!p)
失败。

这显然是一个非零NULL机器上的坏事。


这对非零NULL机器很好。表达!p

表示p!= 0。这意味着p!= NULL。所有三个表达式

都由C标准保证产生相同的结果。

任何人都可以提供现代机器/系统的具体示例
它们嵌入式或超级计算机NULL不为零?
References are always made to systems or machienes that use values
other than zero to represent the NULL pointer.
("Always"?)
Although not a practice I follow, there are no doubt millions of lines
of open source libraries and applications that do things like:

p = malloc(...);
if (!p)
fail.

Which is obviously a bad thing on non-zero NULL machines.
This is fine on "non-zero NULL machines". The expression "!p"
means "p != 0" which means "p != NULL". All three expressions
are guaranteed by the C Standards to produce the same result.
Can anybody provide specific examples of modern machines/systems be
them embedded or supercomputer where NULL is not zero?




定义现代。我的定义是自1965年以来所做的任何事情,

,在这种情况下,PR1ME符合资格。在原始的PR1ME上,一个

NULL指针在内部表示为017777600000(参见

< http://seclists.org/linux-kernel/2000/Jul/0872 .html>)。


尽管如此,PR1ME的C编译器必须转向:


if(!p)...


进入测试p以查看它是否为017777600000指令序列

(如果是这样,执行...部分)。

-

In-Real-Life :风河系统Chris Torek

美国犹他州盐湖城(40°39.22''N,111°50.29''W)+1 801 277 2603

电子邮件:忘了它 http://web.torek.net/torek/index .html

由于垃圾邮件发送者,阅读电子邮件就像在垃圾中搜索食物一样。



Define "modern". My definition is "anything made since 1965",
in which case the PR1ME qualifies. On the original PR1ME, a
NULL pointer is represented internally as 017777600000 (see
<http://seclists.org/linux-kernel/2000/Jul/0872.html>).

Nonetheless, a C compiler for the PR1ME must turn:

if (!p) ...

into a "test p to see if it is 017777600000" instruction sequence
(and if so, execute the "..." part).
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22''N, 111°50.29''W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.


这篇关于NULL不为零的机器的引用。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆