Bug 14709 – dmd/samples/listener.d socket.accept exception handling is incorrect

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2015-06-17T18:57:00Z
Last change time
2015-08-31T12:03:44Z
Keywords
pull
Assigned to
nobody
Creator
kelethunter

Comments

Comment #0 by kelethunter — 2015-06-17T18:57:14Z
In commit 1910c6dabd357c644c07bbb6143ffcef8d8dde6a the exception handling in dmd/samples/listener.d was changed from the original try, catch to a scope(failure). Which is fine; however, line 84 and beyond shows: >Socket sn = listener.accept(); >scope (failure) >{ > writefln("Error accepting"); > > if (sn) > sn.close(); >} If listener.accept() generates an exception, the example will die with that exception, as the scope(failure) comes after the call. I think it should be something like this: >Socket sn = void; >scope (failure) >{ > writefln("Error accepting"); > > if (sn) > sn.close() >} >Socket sn = listener.accept();
Comment #1 by dlang-bugzilla — 2015-08-31T10:07:29Z
Comment #2 by github-bugzilla — 2015-08-31T12:03:44Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/90fe10c35f398d6c787d81eec83fd46df7192f46 fix Issue 14709 - dmd/samples/listener.d socket.accept exception handling is incorrect https://github.com/D-Programming-Language/dmd/commit/969c85db595b56664c31c3291ed1a5992486886e Merge pull request #5000 from CyberShadow/pull-20150831-100433 fix Issue 14709 - dmd/samples/listener.d socket.accept exception hand…