public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gjl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/56263] [avr] Provide strict address-space checking
Date: Tue, 19 Feb 2013 17:59:00 -0000	[thread overview]
Message-ID: <bug-56263-4-zogFDnnakJ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-56263-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56263

--- Comment #4 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2013-02-19 17:58:36 UTC ---
(In reply to comment #3)
> (In reply to comment #2)
> 
>> This cannot work because ISO/IEC TR18037 forces these literals into generic
>> space.
>> 
> 
> ISO/IEC TR18037
> 5.1.2 Address-space type qualifiers:
> 
> If the type of an object is qualified by an address space name, the
> object is allocated in the specified address space; otherwise, the object is
> allocated in the generic address space.
> 
> I just re-read the standard.
> I could not find any reason not permitted to place the data in __flash address
> space in that case:
> 
> const char __flash* const __flash names[] = {"flash_str1", "flash_str2"};

The initializer at the righ side has type "const char *const[]" thus names[] is
located in flash because names[] is qualified __flash.  However, the Embedded C
does not say anything about the literals like "flash_str1" of type "const
char*".  Therefore, vanilla C applies which says that these literals go into
generic space.

> IAR compilers it does, and that hinders gcc do the same?
> I think it's an easy misunderstanding, preventing common sense ...

It's a shortcoming in the Embedded C paper and I agree with you that more
elaborate Embedded C paper would be more convenient here.

There are two ways out of this:

1) Extend the Embedded C paper and propose an addendum to the ISO WG14.

2) Implement this extension no matter whether Embedded C comes with this
extension.  Find someone who implements this extension, supports it and makes
sure there are no conflicts with the vanilla Embedded C.

Notice that with the extension, in the following example "init" would be
located in flash but "assign" would still be located in RAM.

void f_init (void)
{
    const __flash char *str = "init";
}

void f_assign (void)
{
    const __flash char *str;
    str = "assign";
}


  parent reply	other threads:[~2013-02-19 17:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-09 10:30 [Bug target/56263] New: " gjl at gcc dot gnu.org
2013-02-09 10:31 ` [Bug target/56263] " gjl at gcc dot gnu.org
2013-02-10 12:25 ` demiurg_spb at freemail dot ru
2013-02-11 15:10 ` gjl at gcc dot gnu.org
2013-02-11 15:10 ` gjl at gcc dot gnu.org
2013-02-12  6:48 ` demiurg_spb at freemail dot ru
2013-02-19 17:59 ` gjl at gcc dot gnu.org [this message]
2013-02-20  5:54 ` demiurg_spb at freemail dot ru
2013-03-12 11:42 ` gjl at gcc dot gnu.org
2013-03-12 21:21 ` gjl at gcc dot gnu.org
2013-03-13  6:46 ` demiurg_spb at freemail dot ru
2013-03-22 14:48 ` jakub at gcc dot gnu.org
2013-04-20  5:11 ` gjl at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-56263-4-zogFDnnakJ@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).