Article View: comp.std.c
Article #4888Re: integral types in switch expressions
From: Konrad Schwarz
Date: Wed, 13 Mar 1996 20:52
Date: Wed, 13 Mar 1996 20:52
21 lines
1102 bytes
1102 bytes
I recently wished for an extension of the switch statement, allowing not
only constant integral expressions but also constant pointer expressions in
case labels. In private email, Chris Torek (torek@elf.bsdi.com)
has pointed out that it is undecideable at compile-time if two constant
pointer expressions are in fact equal. Given
extern int a [N], b;
``a + N == &b'' is allowable; it is easy to construct
situations where this is detectable only at link time. In this case,
the following fragment is no longer well-defined:
int *p;
switch (p) {
case a + N: ...
case &b: ...
}
and that is the death knell of my proposal.
Konrad Schwarz
Technical Details
Message-ID:
<4i7cht$osd@news.tuwien.ac.at>Path:
arc1-ca.pugleaf.net!mips.complang.tuwien.ac.at!schwarzReferences:
<DnKnzv.8t6%spenford@zoo.toronto.edu> <Dnt4vo.Gu0@tigadmin.ml.com> <4i3s1r$s4o@news.tuwien.ac.at>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mips.complang.tuwien.ac.at!schwarz From: schwarz@mips.complang.tuwien.ac.at (Konrad Schwarz) Newsgroups: comp.std.c Subject: Re: integral types in switch expressions Date: 13 Mar 1996 20:52:13 GMT Organization: TU Wien Message-ID: <4i7cht$osd@news.tuwien.ac.at> References: <DnKnzv.8t6%spenford@zoo.toronto.edu> <Dnt4vo.Gu0@tigadmin.ml.com> <4i3s1r$s4o@news.tuwien.ac.at> NNTP-Posting-Host: mips.complang.tuwien.ac.at