This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: const static initializers versionitis
Thx Alexandre
-fpermissive seems not to be the solution ...
$ g++ -fpermissive -c yy.cpp
yy.cpp:7: uninitialized const `bar'
yy.cpp:9: uninitialized const `tar'
> const POD must be initialized. ....
So how does one forward declare a const POD ? As you can see in the
code the arrays point to each other !
I have 2 applications I want to move to the later C++ compiler and both
applications generate code with statically initialized arrays of various
kinds of objects which should be declared const.
So it seems as though the rule "const POD must be initialized" would
preclude initializing these kind of data structures - kind of weak
wouldn't
you say ?
So the alternative would be to not make them const and not make them
static and then we pollute the name space - which is also bad - .
Do you know what the motivation is behind this rule ? Is it just silly
or
is there a reason for the madness ?
G
Alexandre Oliva wrote:
> On Aug 22, 2000, Gianni Mariani <gianni_@uluru.mariani.ws> wrote:
>
> > Why were forward declarations of const arrays removed from g++
> > since 2.95.2 ?
>
> `extern' is the keyword to forward-declare data in namespace scope.
>
> > Isn't this a gcc bug?
>
> Nope.
>
> > The code still compiles fine in gcc so I would have some level
> > of expectation that "const"ness should not change the behaviour
> > of the compiler.
>
> const POD must be initialized.
>
> > Is there a compiler switch that reinstates the desired behaviour ?
>
> -fpermissive, maybe?
>
> --
> Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
> Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
> CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
> Free Software Evangelist *Please* write to mailing lists, not to me