public inbox for
 help / color / mirror / Atom feed
From: Georg-Johann Lay <>
To: Paul Iannetta <>,
	Jason Merrill <>
Subject: Re: [PATCH v3] c++: parser - Support for target address spaces in C++
Date: Thu, 3 Nov 2022 14:38:39 +0100	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

> [PATCH v3] c++: parser - Support for target address spaces in C++

First of all, it is great news that GCC is going to implement named 
address spaces for C++.

I have some questions:

1. How is name-mangling going to work?

Clang supports address spaces in C++, and for address-space 1 it does 
generate code like the following:

#define __flash __attribute__((__address_space__(1)))

char get_p (const __flash char *p)
     return *p;


I.e. address-space 1 is mangled as "AS1".

(Notice that Clang's attribute actually works like a qualifier here, one 
could not get this to work with GCC attributes.)

2. Will it work with compound literals?

Currently, the following C code works for target avr:

const __flash char *pHallo = (const __flash char[]) { "Hallo" };

This is a pointer in RAM (AS0) that holds the address of a string in 
flash (AS1) and is initialized with that address. Unfortunately, this 
does not work locally:

const __flash char* get_hallo (void)
     [static] const __flash char *p2 = (const __flash char[]) { "Hallo2" };
     return p2;

foo.c: In function 'get_hallo':
foo.c: error: compound literal qualified by address-space qualifier

Is there any way to make this work now? Would be great!


Currently there is target hook TARGET_ADDR_SPACE_DIAGNOSE_USAGE.
I did not see it in your patches, so maybe I just missed it? See

4. Will it be possible to put C++ virtual tables in ASs, and how?

One big complaint about avr-g++ is that there is no way to put vtables 
in flash (address-space 1) and to access them accordingly.  How can this 
be achieved with C++ address spaces?

Background: The AVR architecture has non-linear address space, and you 
cannot tell from the numeric value of an address whether it's in RAM or 
flash. You will have to use different instructions depending on the 

This means that .rodata must be located in RAM, because otherwise one 
would not know whether const char* pointed to RAM or flash, but to 
de-reference you's need different instructions.

One way out is named address spaces, so we could finally fix



  parent reply	other threads:[~2022-11-03 13:38 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-06 14:34 [RFC] " Paul Iannetta
2022-10-06 17:34 ` Jason Merrill
2022-10-09 16:12   ` [PATCH] " Paul Iannetta
2022-10-10 19:20     ` Jason Merrill
2022-10-11 22:03       ` [PATCH v2] " Paul Iannetta
2022-10-12  1:49         ` Jason Merrill
2022-10-13  0:52           ` Paul Iannetta
2022-10-13  5:46             ` Jakub Jelinek
2022-10-13 15:14               ` Paul Iannetta
2022-10-13 15:02             ` Jason Merrill
2022-10-13 15:23               ` Paul Iannetta
2022-10-13 15:47                 ` Jason Merrill
2022-10-13 16:02                   ` Paul Iannetta
2022-10-13 19:41                     ` Jason Merrill
2022-10-13 21:57                       ` Paul Iannetta
2022-10-14 15:19                         ` Jason Merrill
2022-10-18  7:37                           ` [PATCH v3] " Paul Iannetta
2022-10-18 14:24                             ` Jason Merrill
2022-10-18 17:01                               ` Paul Iannetta
2022-10-19 18:55                                 ` Jason Merrill
2022-10-26  7:18                                   ` Paul Iannetta
2022-10-26 16:28                                     ` Jason Merrill
2022-11-10 15:42                                       ` [PATCH v4] " Paul Iannetta
2022-11-03 13:38                                     ` Georg-Johann Lay [this message]
2022-11-10 14:08                                       ` [PATCH v3] " Paul Iannetta
2022-11-10 16:40                                         ` Georg-Johann Lay
2022-11-14 17:55                                           ` Jason Merrill
2022-11-15 12:15                                             ` Georg-Johann Lay

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:

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

  git send-email \ \ \ \ \ \

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