www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20610] New: const in a .tupleof loop is ignored


          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 puremagic.com
          Reporter: andrej.mitrovich 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.

Feb 25 2020