mercredi 2 décembre 2015

Unsequenced modification warning becomes result unused warning in C++11

I'm experimenting with this filters library, and getting an unsequenced modification warning from the following snippet.

while (--numSamples >= 0)
    *dest++ = state.process(*dest, *this);

This makes sense looking at similar questions on SO, as dest is being modified and accessed in the same command. So, I guess the intended functionality is the following . . .

while (--numSamples >= 0) {
    *dest = state.process(*dest, *this);
    *dest++;
}

However, this gives a new, more curious warning "warning: expression result unused" for the post increment. Why this new warning, and how should I fix this correctly?

Aucun commentaire:

Enregistrer un commentaire