public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/9540: C99 initializers generate lots of code
@ 2003-02-02 22:15 bangerth
  2003-02-03 12:34 ` Marius Bernklev
  0 siblings, 1 reply; 4+ messages in thread
From: bangerth @ 2003-02-02 22:15 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, mariube+gcc+, nobody

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c/9540: C99 initializers generate lots of code
  2003-02-02 22:15 c/9540: C99 initializers generate lots of code bangerth
@ 2003-02-03 12:34 ` Marius Bernklev
  0 siblings, 0 replies; 4+ messages in thread
From: Marius Bernklev @ 2003-02-03 12:34 UTC (permalink / raw)
  To: bangerth; +Cc: gcc-bugs, gcc-prs, nobody, gcc-gnats

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c/9540: C99 initializers generate lots of code
@ 2003-02-03 12:36 Marius Bernklev
  0 siblings, 0 replies; 4+ messages in thread
From: Marius Bernklev @ 2003-02-03 12:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c/9540; it has been noted by GNATS.

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 13:34:19 +0100

 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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* c/9540: C99 initializers generate lots of code
@ 2003-02-02 20:16 mariube+gcc+
  0 siblings, 0 replies; 4+ messages in thread
From: mariube+gcc+ @ 2003-02-02 20:16 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9540
>Category:       c
>Synopsis:       C99 initializers generate lots of code
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 02 20:16:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     mariube+gcc+@ifi.uio.no
>Release:        3.2.1
>Organization:
>Environment:
x86
>Description:
When using C99 initializers, i.e.:

    struct bleh *blah = malloc( sizeof *blah );

    *blah = (struct bleh){ .field1 = value1, ... };

the code generated is far bigger than the traditional

    blah->field1 = value1; ...

>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-02-03 12:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-02 22:15 c/9540: C99 initializers generate lots of code bangerth
2003-02-03 12:34 ` Marius Bernklev
  -- strict thread matches above, loose matches on Subject: below --
2003-02-03 12:36 Marius Bernklev
2003-02-02 20:16 mariube+gcc+

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