public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Marius Bernklev <gcc-bugs@gcc.gnu.org>
To: bangerth@dealii.org
Cc: gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org,
	gcc-gnats@gcc.gnu.org
Subject: Re: c/9540: C99 initializers generate lots of code
Date: Mon, 03 Feb 2003 12:34:00 -0000	[thread overview]
Message-ID: <3cf8ywxpmpg.fsf@trebisacce.ifi.uio.no> (raw)
In-Reply-To: <20030202221557.18238.qmail@sources.redhat.com> (bangerth@dealii.org's message of "2 Feb 2003 22:15:57 -0000")

bangerth@dealii.org writes:

> Synopsis: C99 initializers generate lots of code
>
> State-Changed-From-To: open->feedback
> State-Changed-By: bangerth
> State-Changed-When: Sun Feb  2 22:15:57 2003
> State-Changed-Why:
>     Can you send a self-contained code example that shows this?
>     
>     Thanks
>      Wolfgang
>
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9540
>

Certainly. :)


Here goes:


// Start of vector.c
#include <stdlib.h>  // well, I need size_t

// imaginary garbage collector allocator
extern void *gc_malloc(size_t);

struct string {
  size_t size;
  size_t length;
  char *restrict string;
  int hash;
};

struct string *new_vector1( const size_t length ) {
  struct string *const restrict result = gc_malloc( sizeof *result );

  *result = (struct string) { .size = sizeof *result,
                              .length = length,
                              .string = gc_malloc( length ),
                              .hash = -1 };

  return result;
}

struct string *new_vector2( const size_t length ) {
  struct string *const restrict result = gc_malloc( sizeof *result );

  result->size = sizeof *result;
  result->length = length;
  result->string = gc_malloc( length );
  result->hash = -1;
  
  return result;
}
---------------------------

with gcc 3.2.1 on x86, with the command line

gcc -std=c99 -S vector.c,

the code generated for new_vector1 is somewhat larger than for
new_vector2.



Marius
-- 
<URL: http://home.ifi.uio.no/~mariube/ >

Life sucks.  Death swallows.


  reply	other threads:[~2003-02-03 12:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-02 22:15 bangerth
2003-02-03 12:34 ` Marius Bernklev [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-02-03 12:36 Marius Bernklev
2003-02-02 20:16 mariube+gcc+

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=3cf8ywxpmpg.fsf@trebisacce.ifi.uio.no \
    --to=gcc-bugs@gcc.gnu.org \
    --cc=bangerth@dealii.org \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@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).