From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: no code generation for c strings Date: Fri, 03 Jun 2016 17:30:12 +0100 Organization: A noiseless patient Spider Message-ID: References: <369391051.486634184.002061.laguest-archeia.com@nntp.aioe.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="fa27e9c62dd412c1b6adffaac11b940a"; logging-data="7541"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ncVq2PstUx4B3YJC5EHpESvySvVAEMQY=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:vVccTMRMVc23j50ekG3VtZKCKbM= sha1:j9KlE2lsUvONYUo77joD+9EFhVk= Xref: news.eternal-september.org comp.lang.ada:30584 Date: 2016-06-03T17:30:12+01:00 List-Id: "Dmitry A. Kazakov" 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.