[PATCH] D10634: Loss of Sign Checker
Daniel Marjamäki
daniel.marjamaki at evidente.se
Mon Aug 3 22:56:34 PDT 2015
danielmarjamaki added a comment.
In http://reviews.llvm.org/D10634#217433, @soumitra wrote:
> In http://reviews.llvm.org/D10634#213835, @zaks.anna wrote:
>
> > I am leaning toward allowing explicit assignments to "-1", like in this case: "unsigned int j = -1". The tool is much more usable if there are few false positives.
>
>
> This is exactly what I started off with, albeit with a plain 'char' instead of 'unsigned int'. We were hitting a runtime issue while porting a large piece of software to AArch64 since the "signedness" of plain char changes across x86 and AArch64, and a negative value was used as a initializer.
I am also still skeptic about this. Ideally there should only be warnings when there is a mistake.
In your example code you showed previously there were portability problems because the signedness changed. A warning for that is ok in my opinion.
If the code says 'unsigned int j = -1;' then there is no such portability problem.
http://reviews.llvm.org/D10634
More information about the cfe-commits
mailing list