Closed Bug 961295 Opened 6 years ago Closed 6 years ago

clusterLoc is used uninitialized in gfx/thebes/gfxGraphiteShaper.cpp

Categories

(Core :: Graphics, defect)

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED INVALID

People

(Reporter: alexhenrie24, Unassigned)

References

(Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0 (Beta/Release)
Build ID: 20131206145143

Steps to reproduce:

I compiled Firefox.


Actual results:

I got an uninitialized varialbe warning on gfx/thebes/gfxGraphiteShaper.cpp:316.


Expected results:

I should not have gotten the warning. The offending code is below. Note how if j != c.baseGlyph, clusterLoc is used uninitialized.

float clusterLoc;
for (uint32_t j = c.baseGlyph; j < c.baseGlyph + c.nGlyphs; ++j) {
    gfxShapedText::DetailedGlyph* d = details.AppendElement();
    d->mGlyphID = gids[j];
    d->mYOffset = roundY ? NSToIntRound(-yLocs[j]) * dev2appUnits :
                  -yLocs[j] * dev2appUnits;
    if (j == c.baseGlyph) {
        d->mXOffset = 0;
        d->mAdvance = appAdvance;
        clusterLoc = xLocs[j];
    } else {
        float dx = rtl ? (xLocs[j] - clusterLoc) :
                         (xLocs[j] - clusterLoc - adv);
        d->mXOffset = roundX ? NSToIntRound(dx) * dev2appUnits :
                               dx * dev2appUnits;
        d->mAdvance = 0;
    }
}
Blocks: buildwarning
The for-loop initializes j = c.baseGlyph, and therefore the first iteration of the loop is guaranteed to set clusterLoc; then subsequent iterations (if any) will use the already-initialized value.

So I think your compiler is incorrect in giving a warning here.
You're right, sorry.
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.