[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Re: Inline vs. ? : operator

From: David Brown
Subject: [avr-gcc-list] Re: Inline vs. ? : operator
Date: Sat, 27 Mar 2010 22:02:03 +0100
User-agent: Thunderbird (Windows/20100228)

Joerg Wunsch wrote:
David Brown <address@hidden> wrote:

Evaluating the result of "p |= BIT(b)" means carrying out the
or-assign, then reading the value of p and returning it.

You're right, I stand corrected.

That's certainly how /I/ interpret the way volatile works in such cases. I believe there is some uncertainty about how it should work in C++ - the same statement /may/ have a different interpretation in C and C++ when volatiles are sort-of read in this way.

All in all, the fact that even experts are not always accurate in such cases suggests that you should stay well away from such code - an explicit "if" is clear, works exactly as intended, and in some cases gives noticeably better code than a logically equivalent "?:" expression.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]