Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] C puzzle
- Date: Tue, 30 Jul 2002 22:02:22 -0400
- From: Viktor Pavlenko <vvp@example.com>
- Subject: Re: [tlug] C puzzle
- References: <095a01c2382c$bb9e37a0$253d4ca5@example.com>
>>>>> "ND" == Norman Diamond <ndiamond@example.com> writes: ND> (2) ND> Dereferencing a null pointer is clearly incorrect. An ND> implementation is allowed to do things other than crash, it is ND> allowed to print 20 minus signs. One rather famous ND> implementation, which makes this posting almost on-topic, ND> validly exec'ed rogue when it found a #pragma, and it would be ND> equally valid if it exec'ed rogue when it found a program ND> dereferencing a null pointer. In general I agree. But: 0 address is outside of allowed memory range and SIGSEGV is naturally sent to the program that is trying to use it. In other words, it's undefined but you can expect segfault from the compilers you know on the systems you know (who said C is inherently portable?). Btw, unsigned integer underflow (int*i solution to the puzzle) is undefined too. As well as ~i solution I believe. ND> (3) ND> If a crash is desired, the abort function is pretty well ND> defined to do it. The crash doesn't have to resemble other ND> kinds of crashes, but it's the closest thing we have to a ND> guarantee of getting a crash. That's a very good point, how could I forget about abort(3) :) Viktor
- Follow-Ups:
- Re: [tlug] C puzzle
- From: Josh Glover
- References:
- Re: [tlug] C puzzle
- From: Norman Diamond
Home | Main Index | Thread Index
- Prev by Date: [tlug] Re: ISDN connection woes
- Next by Date: Re: [tlug] C puzzle
- Previous by thread: Re: [tlug] C puzzle
- Next by thread: Re: [tlug] C puzzle
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links