avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] Fixing PR44643 vs. PSTR macro


From: Georg-Johann Lay
Subject: Re: [avr-gcc-list] Fixing PR44643 vs. PSTR macro
Date: Fri, 01 Apr 2011 12:15:15 +0200
User-agent: Thunderbird 2.0.0.24 (X11/20100302)

Joerg Wunsch schrieb:
> 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];}))

Yes, typo.

> 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 ...

Ok. But let me add that without changing PSTR as indicated and with
PR44643 fixed as proposed, building avr-libc 1.6.8 resp. 1.7.1 will
abort because avr-gcc errors on PSTR usage. Thus, it's preferred to
update all versions of avr-libc that are supposed to build with gcc
4.7 before adding fix PR44643 to gcc.

Johann



reply via email to

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