Bug 24226 – operator `~=` appears to lead to useless bound checks
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-11-04T12:59:29Z
Last change time
2023-11-09T09:51:19Z
Assigned to
No Owner
Creator
Basile-z
Comments
Comment #0 by b2.temp — 2023-11-04T12:59:29Z
For the following code:
```
extern(C) int printf(const char* f, ...);
int main()
{
const(char)[] fmt;
fmt ~= "\n\0";
return 0;
}
```
The output assembly show calls related to bound checks https://godbolt.org/z/nKhsEWvoT,
apparently in the runtime functions.
But can bounds be violated here ?
Comment #1 by b2.temp — 2023-11-04T13:35:05Z
oh, that's for size_t overflow I guess.
Comment #2 by razvan.nitu1305 — 2023-11-09T09:51:19Z