comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: no code generation for c strings
Date: Fri, 03 Jun 2016 17:30:12 +0100
Date: 2016-06-03T17:30:12+01:00	[thread overview]
Message-ID: <ly8tymqlpn.fsf@pushface.org> (raw)
In-Reply-To: nireuk$1cnp$1@gioia.aioe.org

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> On 03/06/2016 10:14, Luke A. Guest wrote:
>
>> What I would like to have is have the compiler recognise that I've declared
>> a static char_array and just not generate a call to the secondary stack to
>> allocate a new string. Is this actually possible? -O2/3 still generate the
>> call.
>>
>> S : constant char_array := to_c ("hello" & nul);
>
> S : constant char_array := "hello" & char'val (0);

GCC 6.1.0:

   with Interfaces.C;
   package Char_Arrays is
      use type Interfaces.C.char;
      use type Interfaces.C.char_array;
      S : constant Interfaces.C.char_array :=
        "hello" & Interfaces.C.char'Val (0);
   end Char_Arrays;

generates (x86_64-apple-darwin15)

	.globl _char_arrays__s
	.const
	.align 3
_char_arrays__s:
	.ascii "hello\0"
	.space 2
	.globl _char_arrays_E
	.data
	.align 1
_char_arrays_E:
	.space 2
	.subsections_via_symbols

& similar for arm-eabi.


  parent reply	other threads:[~2016-06-03 16:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-03  8:14 no code generation for c strings Luke A. Guest
2016-06-03  8:25 ` Dmitry A. Kazakov
2016-06-03  9:23   ` Luke A. Guest
2016-06-03  9:37     ` Dmitry A. Kazakov
2016-06-03 14:27       ` G.B.
2016-06-03 17:00         ` Lucretia
2016-06-04  6:31           ` Georg Bauhaus
2016-06-03 16:30   ` Simon Wright [this message]
2016-06-03 17:04     ` Lucretia
2016-06-03 18:45       ` Simon Wright
2016-06-03 20:30         ` Luke A. Guest
2016-06-03 21:25           ` Simon Wright
2016-06-03 21:33             ` Luke A. Guest
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox