[cfe-dev] segfault in CFG creation

Ted Kremenek kremenek at apple.com
Sun Nov 18 11:38:41 PST 2007


On Nov 18, 2007, at 8:38 AM, Nuno Lopes wrote:
> Hi,
>
> I've found a bug in CFGBuilder::WalkAST_VisitDeclSubExprs().
> Test + patch: http://web.ist.utl.pt/nuno.lopes/clang_CFG_segfault.txt
>
> Regards,
> Nuno
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

Hi Nuno,

I think there is a bug here, but it might be a little more insidious  
than your patch implies (there could actually be a problem in  
StmtIterator as well).  I don't have time right now, but I will  
investigate this some more later today (or at the latest, tomorrow).

BTW, the test case you provided does not illustrate the bug at all.   
At least for me, running it with or without your changes to CFG.cpp  
produces valid input.  The following code, however, does produce a  
crash:

// RUN: clang -warn-dead-stores -verify %s
void x() {
         int k, y;
         int abc=1;
         long idx=abc+3*5; // expected-warning {{value stored to  
variable is neve
r used}}
}

The problem has to do with neither decl for k or y having an  
initializer.

Thanks for pointing out the problem.  I'll try and get an updated  
patch soon (which will likely be a variation of yours).

Ted



More information about the cfe-dev mailing list