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

 
 

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

Submitted by:  Volker Kuhlmann <vok>
Submitted on:  Sat 29 Oct 2011 04:20:03 AM UTC  
 
Category: HeaderSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Header files
Status: FixedPercent Complete: 0%
Assigned to: Joerg Wunsch <joerg_wunsch>Open/Closed: Closed
Release: 1.7.1Fixed Release: 1.8.0

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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>
Project AdministratorIn charge of this item.
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>
Project AdministratorIn charge of this item.
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.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by joerg_wunsch (Posted a comment)
  • -unavailable- added by vok (Submitted the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 29 Oct 2011 08:24:30 AM UTCjoerg_wunschOpen/ClosedOpen=>Closed
    Sat 29 Oct 2011 08:24:20 AM UTCjoerg_wunschStatusNeed Info=>Fixed
      Assigned toNone=>joerg_wunsch
      Fixed ReleaseNone=>1.8.0
    Sat 29 Oct 2011 08:14:06 AM UTCjoerg_wunschStatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1