|
From: FERANDELLE P. <pas...@fr...> - 2014-06-25 13:21:43
|
I have a strange behaviour under gdb, when debugging the following C source code (act as example) :
main()
{
int ans = 0;
int isSameRoute = 0;
int taxiPlanStatus = 1;
int TaxiRouteCore_TaxiPlanStateType_NoTaxiPlan = 0;
int commandSource = 1;
int TaxiRouteCore_RouteSource_MANUAL = 0;
int commandType = 1;
int TaxiRouteCore_RouteState_EXPECTED = 0;
int taxiType = 1;
int TaxiRouteCore_PlanStateType_CLEARED = 0;
if (taxiPlanStatus != TaxiRouteCore_TaxiPlanStateType_NoTaxiPlan)
{
isSameRoute = 0;
if (isSameRoute == 0)
{
ans = 0;
}
else
{
if (commandSource == TaxiRouteCore_RouteSource_MANUAL)
{
ans = 1;
}
else
{
if ((commandType == TaxiRouteCore_RouteState_EXPECTED)
&& (taxiType == TaxiRouteCore_PlanStateType_CLEARED))
{
ans = 0;
}
else
{
commandType = 1;
ans = 1;
}
}
}
}
else
{
ans = 1;
}
commandType = 0;
}
Source code is compiled whith gcc -g.
Under gdb 7.2, breakpoint is placed on line 22, then program is run ; we hit breakpoint and continue with step command.
When compiled with gcc 3.2.3, everything is OK ; after breakpoint on 22, next step will go to 50, then ends.
When compiled with gcc 4.5.2, after breakpoint on 22, next step will go to 40 (???), then next step goes to 50 ; on 50, looking at ans variable points that line 40 where we unexpectedly stepped, was in fact not executed : ans is still 0 valued ...
Same behaviour with gcc 4.7.2.
Any idea of what can happened ?
Thanks for your help
Pascal
|