dcoughlin added a comment.

Here is the discussion on cfe-dev. 

What's going on is that the path-sensitive unreachable code checker traverses 
blocks in the unoptimized CFG and emits a diagnostic if a block in that CFG is 
not reachable. But it decides whether a block is reachable by using the 
exploded node graph, which itself refers to the *optimized* CFG.

Normally this isn't a problem because the difference between the unoptimized 
and optimized CFGs is that the latter prunes edges that are trivially false 
(but the two CFGs have the same blocks). Unfortunately, there is a bug in CFG 
construction for do-while loops that also prunes a block. Since the block ids 
are constructed sequentially, the block IDs between the two CFGs don't match up 
and so the unreachable code checker gets confused.

I think the best fix here is to change construction of the optimized CFG to not 
prune the block in VisitDoStmt(). This matches what I think is the expected 
meaning of the 'PruneTriviallyFalseEdges' CFG option.


cfe-commits mailing list

Reply via email to