[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Fixing PR44643 vs. PSTR macro
From: |
Joerg Wunsch |
Subject: |
Re: [avr-gcc-list] Fixing PR44643 vs. PSTR macro |
Date: |
Thu, 31 Mar 2011 21:27:02 +0200 (MET DST) |
Georg-Johann Lay <address@hidden> wrote:
> This means that at least PSTR in avr-libc from include/avr/pgmspace.h
> must be changed.
>
> The current avr-libc implementation of PSTR, however, reads
>
> #define PSTR(s) (__extension__({static char __c[] PROGMEM = (s);
> &__c[0];}))
>
> Which should read instead
>
> #define PSTR(s) (__extension__({static char __c[] PROGMEM = (s);
> (const char*) &__c[0];}))
>
> #define PSTR(s) (__extension__({static char __c[] PROGMEM = (s);
> &__c[0];}))
Hmm, the latter appears to be a typo? I assume you meant
#define PSTR(s) (__extension__({static const char __c[] \
PROGMEM = (s); &__c[0];}))
That would be my proposal (though I didn't try it yet).
> This means that the patch will most probably trigger bunch of
> warnings/errors on much code in user land.
Hmm, a progmem pointer that is not qualified to point to a const
object does not make sense anyway. The PSTR() macro is documented
to return a pointer to a const object:
#define PSTR (s)((const PROGMEM char *)(s))
so assigning it to a different pointer has always been a usage error.
I'd say we've survived more annoying (and more benign) warnings like
"pointer target differ in signedness" one in the past ...
--
cheers, J"org .-.-. --... ...-- -.. . DL8DTL
http://www.sax.de/~joerg/ NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)