1 msgRETRACTED: Precompiled headers making for some ...
3 msgcan i cross compile glibc then copy it to the h...
1 msgPrecompiled headers making for some odd trouble...
3 msgSimilarities between gcc and binutils
1 msgTracking down a difference in test_results for ...
2 msgautovectorization and aligned access
3 msgany companies provide services for building gcc...
2 msgSolaris 64 bit build environment
9 msgQuestion on warnings for compiling gcc from svn...
4 msgHow to use GCC testsuite..?
3 msgoption to see the Intermediate repersantation (...

c++ const aggregate vs constructor
\ Kevin Yohe (25 Jun 2007)
. \ John Love-Jensen (26 Jun 2007)
. \ Daniel Lohmann (26 Jun 2007)
. \ Xiaolong Tang (26 Jun 2007)

2 msgvarargs
1 msgRe: relation between gcc/glibc version and linu...
3 msgThe (black?) art of inlining...
3 msgorder of -L options created by gcc for the linker
1 msgloop peeling in autovectorization
3 msgBuilding gcc 4.2.0 cross-compiler (host=i386-ap...
5 msgBuilding only C++ libraries
1 msgCan we use GCC testsuite to test other C compil...
Subject:Re: c++ const aggregate vs constructor
Group:Gcc-help
From:Xiaolong Tang
Date:26 Jun 2007



On Jun 25, 2007, at 4:59 PM, Kevin Yohe wrote:

> Hi,
>
> I am trying to define a constant table that can be initialized at
> compile-time and linked into ROM. I had envisioned two ways of
> defining
> this; either
>
> struct sAggregate
> {
> int m0;
> int m1;
> int m2;
> int m3;
> };
>
> const sAggregate table1[] =
> { { 0, 0, 0, 0 },
> { 1, 1, 1, 1 },
> { 2, 2, 2, 2 },
> { 3, 3, 3, 3 }
> };

As a POD type, this initialization is called static initialization
(from constants) , which shall be
performed at compile time (most implementation).

> or
>
> struct sConstruct
> {
> int m0;
> int m1;
> int m2;
> int m3;
>
> sConstruct( a0, a1, a2, a3 )
> : m0(a0), m1(a1), m2(a2), m3(a3)
> {};
> };
>
> const sConstruct table2[] =
> { sConstruct( 0, 0, 0, 0 ),
> sConstruct( 1, 1, 1, 1 ),
> sConstruct( 2, 2, 2, 2 ),
> sConstruct( 3, 3, 3, 3 )
> };
>

On the contrary, this is not a POD type (user_declared constructors)
, and is dynamic initialization happening at run time.
'cause this direct initialization might involve constructor resolution.

Am I rit?

>



© 2004-2008 readlist.com