Bug 3233 – final switch could skip bounds checking in release mode

Status
NEW
Severity
enhancement
Priority
P5
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2009-08-07T15:00:40Z
Last change time
2024-12-13T17:50:30Z
Keywords
performance
Assigned to
No Owner
Creator
ponce
Moved to GitHub: dmd#17507 →

Comments

Comment #0 by aliloko — 2009-08-07T15:00:40Z
It would allow faster (fastest ?) dynamic dispatch.
Comment #1 by aliloko — 2020-12-19T01:59:50Z
For example: See godbolt output in https://d.godbolt.org/z/7x3Ehd --------------- switch.d --------------------- enum LOL { a, b, c } import core.stdc.stdio; void dosmthg(LOL l) { assert(l >= LOL.a); assert(l <= LOL.c); final switch(l) with (LOL) { case a: printf("hello"); case b: printf("world"); case c: printf("!!!!"); } } ---------------------------------------------- The final switch always has a default case that call core.internal.switch_error I'm not really if this is a good thing or not. On one hand, it's like a enabled-on-release assertion so a good idea. On the other hand, it's one more test in a final switch that could assume all values are inside range. Maybe it's better to err on the side of safe.
Comment #2 by aliloko — 2023-12-17T15:09:36Z
Please close this :)
Comment #3 by robert.schadek — 2024-12-13T17:50:30Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17507 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB