Is this a bug?
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Nov 27 10:43:01 PST 2013
On Wed, Nov 27, 2013 at 02:06:33AM -0500, Jerry wrote:
> Jerry <jlquinn at optonline.net> writes:
>
> > "H. S. Teoh" <hsteoh at quickfur.ath.cx> writes:
> >
> >> On Tue, Nov 26, 2013 at 06:33:28PM -0500, Jerry wrote:
> >>> If I read correctly, the following is legal code. If you comment out
> >>> one of the case statements, it does the expected thing. With 4 or more,
> >>> it crashes. This is with dmd 2.064.2 on Debian.
> >>>
> >>> If it's a bug, I'll file a report. Thanks!
> >>>
> >>> class BB {}
> >>> class DD : CC {}
> >>> class CC : BB {
> >>> static CC create(string s) {
> >>> // Succeeds with 3 cases, fails with 4
> >>> switch (s) {
> >>> case "en":
> >>> case "it":
> >>> case "ru":
> >>> case "ko": return new DD;
> >>> default: throw new Exception("blech");
> >>> }
> >>> }
> >>> }
> >>>
> >>> void main() {
> >>> CC.create("en");
> >>> }
> >>>
> >>> jlquinn at wyvern:~/d$ ~/dmd2/linux/bin64/dmd switchbug.d -g
> >>> jlquinn at wyvern:~/d$ ./switchbug
> >>> Segmentation fault (core dumped)
> >> [...]
> >>
> >> No crash on dmd git HEAD, Debian/unstable (x86_64).
> >>
> >
> > If I build dmd from the sources, the program works. It's only the
> > precompiled dmd executable that generates a broken binary.
>
> Sorry, not true. I had the extra case commented out. Uncommenting it
> still gives me a crashing program.
Strange. I tested again on both git HEAD and 2.064.2, and I still don't
get any crashes. This is on Debian/unstable (x86_64). I added a few more
calls to CC.create, just to make sure the switch branches all work as
expected; here is my test code:
------
class BB {}
class DD : CC {}
class CC : BB {
static CC create(string s) {
// Succeeds with 3 cases, fails with 4
switch (s) {
case "en":
case "it":
case "ru":
case "ko": return new DD;
default: throw new Exception("blech");
}
}
}
void main() {
CC.create("en");
CC.create("it");
CC.create("ru");
CC.create("ko");
}
------
Are you sure your copy of dmd isn't picking up the wrong version(s) of
the runtime libraries? Maybe try compiling with dmd -v to see if the
include paths and library paths are what you expect?
T
--
GEEK = Gatherer of Extremely Enlightening Knowledge
More information about the Digitalmars-d
mailing list