Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!think!ima!haddock!karl From: karl@haddock Newsgroups: net.lang.c Subject: Re: Dead functions and /*NOTREACHED*/ Message-ID: <86900037@haddock> Date: Wed, 3-Sep-86 15:21:00 EDT Article-I.D.: haddock.86900037 Posted: Wed Sep 3 15:21:00 1986 Date-Received: Wed, 3-Sep-86 21:55:19 EDT References: <410@epimass.UUCP> Lines: 33 Nf-ID: #R:epimass.UUCP:410:haddock:86900037:000:1522 Nf-From: haddock!karl Sep 3 15:21:00 1986 epimass!jbuck (Joe Buck) writes: >In article <86900019@haddock> karl@haddock (The Walking Lint) writes: >>[discussion of some problems with adding "dead functions" to C] >>But I really hate having to write /*NOTREACHED*/ to keep lint happy! > >There's a fix for this that doesn't do violence to the language. >There should be another "special comment" lint recognizes that's >present in the lint library (/*DEADEND*/ or something). Then >functions like "exit" are marked once in the lint library, and >user-written functions that always call exit would also be understood >to be "dead". Voila! lint now understands about exit, and is able >to find unreachable code that it currently may miss. (I don't think adding a new type is "violence to the language", but...) Not bad; it doesn't help with the compiler's optimization, but it would take care of the /*NOTREACHED*/ problem. And the user can use /*DEADEND*/ on his own functions even if lint isn't smart enough to propagate dead-knowledge. (If it is, then the magic comment may not even be necessary; the line void exit(int) { for (;;); } int the lint library should suffice.) >While I'm at it, a similar comment could be added to tell lint that >a function like malloc or calloc always returns an aligned pointer. Perhaps. >I understand that ANSI C has a different solution for this, No. "void *" has nothing to do with guaranteed alignment, it just means "pointer to unknown". Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint