digitalmars.D.bugs - [Issue 8844] New: Warning for bug-prone operator overloading
- d-bugmail puremagic.com (28/28) Oct 17 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8844
- d-bugmail puremagic.com (13/13) Oct 18 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8844
http://d.puremagic.com/issues/show_bug.cgi?id=8844 Summary: Warning for bug-prone operator overloading Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: diagnostic Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc --- Comment #0 from bearophile_hugs eml.cc 2012-10-17 15:46:15 PDT --- struct Foo { Foo opBinary(string op="-")(Foo f) { return Foo(); } } void main() { auto Foo = Foo() + Foo(); } Compiles and run with no errors, dmd 2.061alpha, because "-" is a default argument for the op template argument, so that code is formally correct. But I'd like a warning here (or an error?), because I think such code is bug-prone. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 17 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8844 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com --- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-10-18 11:28:48 PDT --- Technically it's still callable: auto Foo = Foo().opBinary(Foo()); But I don't know why someone would explicitly call opBinary without operators. Making it an error could help catch bugs though. +1 from me. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 18 2012