bugAVR C Runtime Library - Bugs: bug #56093, Wrong constraint in...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #56093: Wrong constraint in pgmspace.h::pgm_get_far_address

Submitter:  Georg-Johann Lay <gjlayde>
Submitted:  Sun 07 Apr 2019 01:00:58 PM UTC
   
 
Category:  Header Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Header files
Status:  None Assigned to:  None
Percent Complete:  0% Open/Closed:  Open
Release:  2.0.0 Fixed Release:  None

Sun 07 Apr 2019 01:00:58 PM UTC, original submission:  

Macro pgm_get_far_address() from avr/pgmspace.h has a wrong constraint for operand %1: Is must be "ni" (known at compile-time (n) or known ar assembly time or later (i)) instead of "p".

Moreover, the asm is not volatile, hence the "volatile" can be dropped.

The "tmp" should also be recplaced by an identifier from implementation space like __tmp.

Last not least, the macro should come with "extension" so that it will work in strict C mode (and not only with GNU-C which valued blocks are).

Putting everything together, the macro should read


#define pgm_get_far_address(var)                      \
(__extension__({                                      \
    uint_farptr_t __tmp;                              \
                                                      \
    __asm__ (                                         \
            "ldi    %A0, lo8(%1)"           "\n\t"    \
            "ldi    %B0, hi8(%1)"           "\n\t"    \
            "ldi    %C0, hh8(%1)"           "\n\t"    \
            "clr    %D0"                    "\n\t"    \
        : "=d" (__tmp)                                \
        : "ni" (&(var))                               \
    );                                                \
    __tmp;                                            \
}))


Georg-Johann Lay <gjlayde>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gjlayde (Submitted the item)
  •  

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code