www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13899] New: Unwanted warning for pure opApply


          Issue ID: 13899
           Summary: Unwanted warning for pure opApply
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: bearophile_hugs eml.cc

I think the compiler should not generate a warning in this case:

const struct Foo {
    int opApply(immutable int delegate(in ref int) pure nothrow dg)
    pure nothrow {
        return 1;
void main() {
    foreach (x; Foo()) {}

dmd 2.067alpha gives:

test.d(7,5): Warning: calling test.Foo.opApply without side effects discards
return value of type int, prepend a cast(void) if intentional

Dec 27 2014