digitalmars.D.bugs - [Issue 4558] New: To spot a possible bug in code that doesn't change a value
- d-bugmail puremagic.com (36/36) Aug 01 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4558
http://d.puremagic.com/issues/show_bug.cgi?id=4558
Summary: To spot a possible bug in code that doesn't change a
value
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
This is a semantically wrong D2 program, the programmer has used a "&=" instead
of "|=" to build a flag result:
enum Flags { NONE = 0b00,
FIRST = 0b01,
SECOND = 0b10
}
Flags foo(int x) {
Flags result = Flags.NONE;
if (x < 10)
result |= Flags.FIRST;
else
result &= Flags.SECOND; // line 10
return result;
}
void main() {}
The D compiler can find this problem in the code at line 10 because in that
program the variable "result" is certantly zero after the assignment with
Flags.SECOND, so it's an error or it's useless code.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 01 2010








d-bugmail puremagic.com