www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24226] New: operator `~=` appears to lead to useless bound

https://issues.dlang.org/show_bug.cgi?id=24226

          Issue ID: 24226
           Summary: operator `~=` appears to lead to useless bound checks
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: b2.temp gmx.com

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 ?

--
Nov 04 2023