AVR C Runtime Library - Bugs: bug #37026, ABI documentation and 8-bit...
You are not allowed to post comments on this tracker with your current authentication level.
bug #37026: ABI documentation and 8-bit integer promotion of function return
Submitter: | Georg-Johann Lay <gjlayde> | ||
Submitted: | Sat 04 Aug 2012 12:48:57 PM UTC | ||
Category: | Documentation | Severity: | 3 - Normal |
Priority: | 9 - Immediate | Item Group: | Documentation |
Status: | None | Assigned to: | None |
Percent Complete: | 0% | Open/Closed: | Open |
Release: | 1.8.0 | Fixed Release: | None |
No files currently attached
Depends on the following items: None found
Items that depend on this one: None found
Carbon-Copy List
Follows 1 latest change.
Date | Changed by | Updated Field | Previous Value | => | Replaced by |
---|---|---|---|---|---|
2012-11-16 | arcanum | Priority | 5 - Normal | 9 - Immediate |
Powered by Savane 3.13-cf05.
Corresponding source code
The current ABI documentation [1] reads:
avr-gcc up to 4.2 actually performed that promotion. However, that promotion was not per design, it was just a missed optimization in the compiler (and thus is not suposed to work reliably) and since 4.3 (including respective WinAVR releases) that promotion is no more performed.
There were off-list e-mail threads "AVR GCC 8-bit return values" from 2011-04-02 and "[off-list]: Updating avr-gcc ABI" from 2011-04-20 between Eric, Jörg, Denis and me with the conclusion that the above clause shall be dropped from the ABI.
The changed promotion behavior affects assembler code that calls C function with an 8-bit integer return value and expects that the return value is promoted to 16 bits.
Even the older versions <= 4.2 of the compiler that perform the promotion won't make use of that: Suppose a caller that calls a function returning 8-bit, and the caller needs a 16-bit value. Then the caller performs that extention explicitly and does not rely on the callee returning a 16-bit integer. Sample code:
The ABI document should mention that the promotion performed by the compiler changed with 4.2 -> 4.3 and the promotion up to 4.2 does not work reliably.
Moreover (and unrelated to promotion) the ABI should mention that T-flag in SREG is used the same way like R0 aka. _tmp_reg_.