[Issue 20610] New: const in a .tupleof loop is ignored

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 26 07:13:01 UTC 2020


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

          Issue ID: 20610
           Summary: const in a .tupleof loop is ignored
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: andrej.mitrovich at gmail.com

-----
void main ()
{
    struct S
    {
        int what;
    }

    S record;

    foreach (const ref field; record.tupleof)
        field = 10;
}
-----

This compiles fine. It also means that if you try to call a function with this
field, it will not respect the 'const' and will allow you to modify the field.

--


More information about the Digitalmars-d-bugs mailing list