bugAVR C Runtime Library - Bugs: bug #34680, PSTR() should declare a const...

 
 

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

bug #34680: PSTR() should declare a const variable

Submitter:  Volker Kuhlmann <vok>
Submitted:  Sat 29 Oct 2011 04:20:03 AM UTC
   
 
Category:  Header Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Header files
Status:  Fixed Assigned to:  joerg_wunsch
Percent Complete:  0% Open/Closed:  Closed
Release:  1.7.1 Fixed Release:  1.8.0

Sat 29 Oct 2011 10:31:54 AM UTC, comment #3: 

Ok, fixed in 1.7.2rc2 - thanks.
Two reports because of two different issues, though one necessitating the other.

Volker Kuhlmann <vok>
Sat 29 Oct 2011 08:24:20 AM UTC, comment #2: 

Now I see.  I've been confused about the mix of followups
between this PR and bug #28837.

This one here's already fixed.

Joerg Wunsch <joerg_wunsch>
Group administrator
Sat 29 Oct 2011 08:14:06 AM UTC, comment #1: 

I'm not quite sure whether the bug report is only about
PSTR needing to declare the string as "const" (which has
already been present in the SVN version for 5 months), or
whether there's anything else you think should be done.

There's an interim (source) version named "1.7.2rc" on the
server (even though we eventually intend to name the next
release "1.8.0"), can you test whether everything works as
expected with that version?

Joerg Wunsch <joerg_wunsch>
Group administrator
Sat 29 Oct 2011 04:20:03 AM UTC, original submission:  

avr/pgmspace.h defines

# define PSTR(s) (_extension_({static char __c[] PROGMEM = (s); &__c[0];}))

which places the variable into read-only (program flash) memory. This should be marked as const to indicate that the variable will not change.

Because of a gcc bug (4.2? - 4.5) it's necessary to redefine PROGMEM to
#define PROGMEM _attribute_(( section(".progmem.data") ))
to achieve the same effect but without the bogus warning from gcc.
This definition gives a linker error when mixing const and non-const variables in the same section. Placing the const variables into ".progmem.data" and the non-const into ".progmem.datanotreadwriteafterall" works with the same effect, but I don't see how to do that automatically.

See bug #28837, and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734
So to make this all work with correctly programmed source that uses const, make PSTR const as well, which it should have been in tne first place.

Volker Kuhlmann <vok>

 

(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 joerg_wunsch (Posted a comment)
  • -email is unavailable- added by vok (Submitted the item)
  •  

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-10-29 joerg_wunsch Open/ClosedOpen Closed
    2011-10-29 joerg_wunsch StatusNeed Info Fixed
        Assigned toNone joerg_wunsch
        Fixed ReleaseNone 1.8.0
    2011-10-29 joerg_wunsch StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code