From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,baaf5f793d03d420 X-Google-Attributes: gid109fba,public X-Google-Thread: fc89c,97188312486d4578 X-Google-Attributes: gidfc89c,public X-Google-Thread: 103376,97188312486d4578 X-Google-Attributes: gid103376,public X-Google-Thread: 1014db,6154de2e240de72a X-Google-Attributes: gid1014db,public From: seebs@solutions.solon.com (Peter Seebach) Subject: Re: What's the best language to start with? [was: Re: Should I learn C or Pascal?] Date: 1996/08/05 Message-ID: <4u5h81$ol@solutions.solon.com>#1/1 X-Deja-AN: 172289736 references: <01bb826a$b222f400$9bee6fce@timhome2> <4u3tt1$qub@solutions.solon.com> <4u5682$qgs@dawn.mmm.com> organization: Usenet Fact Police (Undercover) reply-to: seebs@solon.com newsgroups: comp.lang.c,comp.lang.c++,comp.unix.programmer,comp.lang.ada Date: 1996-08-05T00:00:00+00:00 List-Id: In article <4u5682$qgs@dawn.mmm.com>, Chris Sonnack wrote: >Peter Seebach (seebs@solutions.solon.com) wrote: >>> This completely makes the point. Someone who knows assembly language >>> would *never* make that mistake, because it would be so obviously >>> wrong. >> An interesting theory. >Not a theory. I've seen it personally. A theory, and a false one, because I've seen an assembly programmer, not only make that mistake, but attempt to justify it based on his "knowledge" of the machine. >Because I know what "" really is under the hood, I know it has nothing in >common with a NULL pointer. And I've seen a co-worker, a fellow professional >who's been doing this for a number of years, make the above mistake. Not >just once, but several times. With no concept at all of how "" really works, it's obvious that it has nothing in common with a null pointer. It's an object, or the address of an object in some contexts, and is very unlikely to have any connection to the null pointer. >Yep. True. (Although, honestly, 90+% of all implementations define NULL >along the lines of: (void*)0) Or just plain 0. They are required to. However, *THIS DOES NOT MEAN IT IS THE ADDRESS 0*. There is no reason to expect that (void *)0 and (void *) 0xFFFFFFFF will not compare equal. 0 must convert to a null pointer. This does *not* mean that a null pointer is a 0. >This is also true. The point is "" is a real object in memory, and any >assembly programmer would know that. What the NULL pointer is doesn't >matter here; the point is that "" ain't the NULL address. But there's nothing wrong with the null address working as a "", and the assumption visibly holds on many machines. A *competent* assembly programmer would never make that mistake. Neither woud a *competent* C programmer. (IMHO.) I don't believe that either the assembly or the non-assembly background grants any protection. People who are inclined to try things and assume that they'll continue to work are dangerous in any language. I would suspect that people who want to learn assembly are slightly more prone to this weakness, but it's hard to be sure. >How's my programming? Call 1-800-DEV-NULL Cute. -s -- Peter Seebach - seebs@solon.com - Copyright 1996 - http://www.solon.com/~seebs Unix/C Wizard - send mail for help, or send money for consulting! The *other* C FAQ, the hacker FAQ, et al. See web page above. Unsolicited email (junk mail and ads) is unwelcome, and will be billed for.