-
Notifications
You must be signed in to change notification settings - Fork 85
cargo mirai never warns me about anything. #1202
Comments
Thanks for opening this issue! so I wasn't doing something wrong? |
Instead of Then you'll see
Why? --diag=paranoid will tell you (sort of):
The subtle answer lies in the This kind of trade-off is very tricky and perhaps the default needs to change. Ultimately that is really up to users. So there are really two issues here:
|
I confirm that setting this environment variable makes MIRAI emit the warnings I expect. I'm not quite sure what you mean by the rest. If I read it correctly, you're saying that the issue was simply that MIRAI doesn't check That said, the test function was defined in the PS edited, hopefully for clarity |
Its a bit more complicated: MIRAI does "whole program analysis", starting from "entry points". In this case the entry point is main and MIRAI checks all of the code that may be reachable from main. The --diag flag controls the kind of error messages you'll see. The basic idea is that there are different kinds of audiences with different needs and expectations. In default mode, very few warnings are displayed. Essentially only those for which there is a high probability that they show up a real error. The problem is how to decide if an error is real or not. When the whole program analysis encounters a function with an unknown body, such as std::env::args_os, it does not know what effect this function will have on the state of the heap, so it goes into conservative mode and suppresses errors that depend on the heap state. In this case the value of args.a. This is, of course, not the outcome we really want for this example and MIRAI needs fixing. I'll see what I can do over the weekend. |
I deleted the previous two comments when I realized that MIRAI wasn't warning about that library file precisely because there was nothing to warn. Apparently the function triggered a false positive when in I can elaborate if you want, but effectively I was looking at a different function than the one above. Adding an undeniably naughty function did trigger the expected warnings. Sorry for the noise. |
Issue
False positive suppression leads to false negatives.
Steps to Reproduce
For example:
Following the instructions, I did:
Expected Behavior
It ought to object strenuously to v[args.a], but I get nothing!
Actual Results
No error.
Environment
rustc 1.70.0-nightly (22f247c6f 2023-03-13)
The text was updated successfully, but these errors were encountered: