Half-inch Gap between wall and floor in second floor bedroom
I called in a competent contractor and here are his findings.  He took up some floorboards next to the gap.  There was a gap between the bottom of the sheet rock wall and the floor. He cut through the subflooring in order to be able to look at the joists. The joists were solid.  There was no indication of infestation. There was an uninsulated heat duct running between the joists.  He went to the basement and checked for termite damage and found none.  His conclusion is that the gap between the second floor wall and floor is due to shrinkage of the wood, exacerbated by the heat duct running nearby.  He said there was no need to do any work as nothing was really wrong.

BTW, there is also a gap between an interior wall and a poured concrete floor in my foyer, but that is not below the gap on the second floor.  The two gaps are independent.  The gap between the wall and the poured concrete floor is due to the dirt below the concrete settling.  The contractor suggested to leave it be since it is not likely to get worse and the fix would be costly for little benefit.

It is nice to deal with an honest, competent contractor.