On Thursday, July 07, 2016 10:33:39 Basile B. via Digitalmars-d-learn wrote: > this compiles without error: > > > struct Foo > { > int i; > void bar() > { > void foo() const > { > i = 1; > } > foo; > } > } > > In this case "const" seems to be a noop. Do you think it's a bug > ? Shouldn't "const" be applied, despite of foo() inaccessibility ?
It makes no sense for const to be used on foo. foo is not a member function, so there's nothing for the const to apply to. So, the compiler is clearly ignoring a nonsensical attribute, which it often does. For better or worse, issues like that tend to be declared to not be bugs, which can make sense in some cases with generic code and mixins but often is just confusing (and in this particular case, I don't see why it would even help with generic code, since it could never apply under any circumstances). So, I'm all for reporting it as a bug, but it wouldn't surprise me if the compiler devs decided that it wasn't one. But regardless, because foo is not a member function, the assignment is completely valid. It's the attribute that isn't. - Jonathan M Davis