public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Peculiar functionality
@ 1999-05-18 17:32 Stephen Lindholm
  1999-05-18 17:45 ` Joe Buck
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Stephen Lindholm @ 1999-05-18 17:32 UTC (permalink / raw)
  To: egcs

Hi.  I'm a long-time C programmer who's finally moving to C++.  I've noticed
some unusual behaviour from egcs 1.1:

1)  The new operators "or" "and" "not" (etc), described on Stroustrup C++PL
3rd ed. p. 829 appear to not exist in egcs, or to be turned off by default.
(It's my feeling that if they are turned off by default, they should be
turned on, since it is perfectly legitimate to use them in C++ code.)

2)  egcs complains when I use arrays of references.  If this is bad style,
please explain why.  I find them to be useful, and do not understand why
egcs complains.  (I have two objects that I initialize one-by-one, then
lasso them together into an array of references so I can refer to them
symmetrically.  I would prefer to not put a default constructor into my
object.  That would be ugly and potentially dangerous.)

3)  I can't make class-local constants!  I must be doing this wrong, since I
can't imagine why this would not be present:

class   TAnneal {
        // How many iterations to run for
        const int    Iterations = 50;

anneal.cpp:16: warning: ANSI C++ forbids initialization of const member
`Iterations'
anneal.cpp:16: warning: making `Iterations' static

Any guidance would be appreciated.

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

* Re: Peculiar functionality
  1999-05-18 17:32 Peculiar functionality Stephen Lindholm
@ 1999-05-18 17:45 ` Joe Buck
  1999-05-31 21:36   ` Joe Buck
  1999-05-18 18:13 ` Alexandre Oliva
  1999-05-31 21:36 ` Stephen Lindholm
  2 siblings, 1 reply; 14+ messages in thread
From: Joe Buck @ 1999-05-18 17:45 UTC (permalink / raw)
  To: Stephen Lindholm; +Cc: egcs

> 1)  The new operators "or" "and" "not" (etc), described on Stroustrup C++PL
> 3rd ed. p. 829 appear to not exist in egcs, or to be turned off by default.
> (It's my feeling that if they are turned off by default, they should be
> turned on, since it is perfectly legitimate to use them in C++ code.)

These are enabled by the flag -foperator-names, or -ansi.  The reason for
not making them the default is that too much old C++ code breaks.

> 2)  egcs complains when I use arrays of references.  If this is bad style,
> please explain why.

Because they aren't C++?

> 3)  I can't make class-local constants!  I must be doing this wrong, since I
> can't imagine why this would not be present:

Your syntax is wrong.

> class   TAnneal {
>         // How many iterations to run for
>         const int    Iterations = 50;
> 
> anneal.cpp:16: warning: ANSI C++ forbids initialization of const member
> `Iterations'
> anneal.cpp:16: warning: making `Iterations' static

Try
	static const int Iterations = 50;

You can initialize const static members this way, but not const fields
that belong to every object of type TAnneal (those have to be initialized
in the constructor).


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

* Re: Peculiar functionality
  1999-05-18 17:32 Peculiar functionality Stephen Lindholm
  1999-05-18 17:45 ` Joe Buck
@ 1999-05-18 18:13 ` Alexandre Oliva
  1999-05-18 19:13   ` Joe Buck
  1999-05-31 21:36   ` Alexandre Oliva
  1999-05-31 21:36 ` Stephen Lindholm
  2 siblings, 2 replies; 14+ messages in thread
From: Alexandre Oliva @ 1999-05-18 18:13 UTC (permalink / raw)
  To: Stephen Lindholm; +Cc: egcs

On May 18, 1999, "Stephen Lindholm" <lind0753@umn.edu> wrote:

> 1)  The new operators "or" "and" "not" (etc), described on Stroustrup C++PL
> 3rd ed. p. 829 appear to not exist in egcs, or to be turned off by default.

Indeed.  Use -foperator-names or -ansi.  I think it is not enabled by
default for fear of breaking header-files that still use them.  Maybe
it's time to turn them on by default, now that we're moving to more
strict ISO C++.

> 2)  egcs complains when I use arrays of references.  If this is bad style,
> please explain why.

Not only bad style, it's ill-formed.  ISO C++ forbids arrays of
references, because references are not objects (in the Standard
sense).

> 3)  I can't make class-local constants!

You can, but you have to declare them as static, otherwise you won't
be allowed to initialize them at the point of declaration.

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
{oliva,Alexandre.Oliva}@dcc.unicamp.br  aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
*** E-mail about software projects will be forwarded to mailing lists

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

* Re: Peculiar functionality
  1999-05-18 18:13 ` Alexandre Oliva
@ 1999-05-18 19:13   ` Joe Buck
  1999-05-18 19:26     ` Alexandre Oliva
  1999-05-31 21:36     ` Joe Buck
  1999-05-31 21:36   ` Alexandre Oliva
  1 sibling, 2 replies; 14+ messages in thread
From: Joe Buck @ 1999-05-18 19:13 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: lind0753, egcs

> On May 18, 1999, "Stephen Lindholm" <lind0753@umn.edu> wrote:
> 
> > 1)  The new operators "or" "and" "not" (etc), described on Stroustrup C++PL
> > 3rd ed. p. 829 appear to not exist in egcs, or to be turned off by default.
> 
> Indeed.  Use -foperator-names or -ansi.  I think it is not enabled by
> default for fear of breaking header-files that still use them.  Maybe
> it's time to turn them on by default, now that we're moving to more
> strict ISO C++.

I don't think we should change it for 2.95; we can try flipping the
default afterwards, leaving the option as -fno-operator-names, in
snapshots and see how bad the damage is.

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

* Re: Peculiar functionality
  1999-05-18 19:13   ` Joe Buck
@ 1999-05-18 19:26     ` Alexandre Oliva
  1999-05-31 21:36       ` Alexandre Oliva
  1999-05-31 21:36     ` Joe Buck
  1 sibling, 1 reply; 14+ messages in thread
From: Alexandre Oliva @ 1999-05-18 19:26 UTC (permalink / raw)
  To: Joe Buck; +Cc: lind0753, egcs

On May 18, 1999, Joe Buck <jbuck@Synopsys.COM> wrote:

> I don't think we should change it for 2.95; we can try flipping the
> default afterwards, leaving the option as -fno-operator-names, in
> snapshots and see how bad the damage is.

Yep, that's kind of what I meant :-)

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
{oliva,Alexandre.Oliva}@dcc.unicamp.br  aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
*** E-mail about software projects will be forwarded to mailing lists

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

* Re: Peculiar functionality
  1999-05-18 18:13 ` Alexandre Oliva
  1999-05-18 19:13   ` Joe Buck
@ 1999-05-31 21:36   ` Alexandre Oliva
  1 sibling, 0 replies; 14+ messages in thread
From: Alexandre Oliva @ 1999-05-31 21:36 UTC (permalink / raw)
  To: Stephen Lindholm; +Cc: egcs

On May 18, 1999, "Stephen Lindholm" <lind0753@umn.edu> wrote:

> 1)  The new operators "or" "and" "not" (etc), described on Stroustrup C++PL
> 3rd ed. p. 829 appear to not exist in egcs, or to be turned off by default.

Indeed.  Use -foperator-names or -ansi.  I think it is not enabled by
default for fear of breaking header-files that still use them.  Maybe
it's time to turn them on by default, now that we're moving to more
strict ISO C++.

> 2)  egcs complains when I use arrays of references.  If this is bad style,
> please explain why.

Not only bad style, it's ill-formed.  ISO C++ forbids arrays of
references, because references are not objects (in the Standard
sense).

> 3)  I can't make class-local constants!

You can, but you have to declare them as static, otherwise you won't
be allowed to initialize them at the point of declaration.

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
{oliva,Alexandre.Oliva}@dcc.unicamp.br  aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
*** E-mail about software projects will be forwarded to mailing lists

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

* Peculiar functionality
  1999-05-18 17:32 Peculiar functionality Stephen Lindholm
  1999-05-18 17:45 ` Joe Buck
  1999-05-18 18:13 ` Alexandre Oliva
@ 1999-05-31 21:36 ` Stephen Lindholm
  2 siblings, 0 replies; 14+ messages in thread
From: Stephen Lindholm @ 1999-05-31 21:36 UTC (permalink / raw)
  To: egcs

Hi.  I'm a long-time C programmer who's finally moving to C++.  I've noticed
some unusual behaviour from egcs 1.1:

1)  The new operators "or" "and" "not" (etc), described on Stroustrup C++PL
3rd ed. p. 829 appear to not exist in egcs, or to be turned off by default.
(It's my feeling that if they are turned off by default, they should be
turned on, since it is perfectly legitimate to use them in C++ code.)

2)  egcs complains when I use arrays of references.  If this is bad style,
please explain why.  I find them to be useful, and do not understand why
egcs complains.  (I have two objects that I initialize one-by-one, then
lasso them together into an array of references so I can refer to them
symmetrically.  I would prefer to not put a default constructor into my
object.  That would be ugly and potentially dangerous.)

3)  I can't make class-local constants!  I must be doing this wrong, since I
can't imagine why this would not be present:

class   TAnneal {
        // How many iterations to run for
        const int    Iterations = 50;

anneal.cpp:16: warning: ANSI C++ forbids initialization of const member
`Iterations'
anneal.cpp:16: warning: making `Iterations' static

Any guidance would be appreciated.

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

* Re: Peculiar functionality
  1999-05-18 17:45 ` Joe Buck
@ 1999-05-31 21:36   ` Joe Buck
  0 siblings, 0 replies; 14+ messages in thread
From: Joe Buck @ 1999-05-31 21:36 UTC (permalink / raw)
  To: Stephen Lindholm; +Cc: egcs

> 1)  The new operators "or" "and" "not" (etc), described on Stroustrup C++PL
> 3rd ed. p. 829 appear to not exist in egcs, or to be turned off by default.
> (It's my feeling that if they are turned off by default, they should be
> turned on, since it is perfectly legitimate to use them in C++ code.)

These are enabled by the flag -foperator-names, or -ansi.  The reason for
not making them the default is that too much old C++ code breaks.

> 2)  egcs complains when I use arrays of references.  If this is bad style,
> please explain why.

Because they aren't C++?

> 3)  I can't make class-local constants!  I must be doing this wrong, since I
> can't imagine why this would not be present:

Your syntax is wrong.

> class   TAnneal {
>         // How many iterations to run for
>         const int    Iterations = 50;
> 
> anneal.cpp:16: warning: ANSI C++ forbids initialization of const member
> `Iterations'
> anneal.cpp:16: warning: making `Iterations' static

Try
	static const int Iterations = 50;

You can initialize const static members this way, but not const fields
that belong to every object of type TAnneal (those have to be initialized
in the constructor).


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

* Re: Peculiar functionality
  1999-05-18 19:26     ` Alexandre Oliva
@ 1999-05-31 21:36       ` Alexandre Oliva
  0 siblings, 0 replies; 14+ messages in thread
From: Alexandre Oliva @ 1999-05-31 21:36 UTC (permalink / raw)
  To: Joe Buck; +Cc: lind0753, egcs

On May 18, 1999, Joe Buck <jbuck@Synopsys.COM> wrote:

> I don't think we should change it for 2.95; we can try flipping the
> default afterwards, leaving the option as -fno-operator-names, in
> snapshots and see how bad the damage is.

Yep, that's kind of what I meant :-)

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
{oliva,Alexandre.Oliva}@dcc.unicamp.br  aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
*** E-mail about software projects will be forwarded to mailing lists

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

* Re: Peculiar functionality
  1999-05-18 19:13   ` Joe Buck
  1999-05-18 19:26     ` Alexandre Oliva
@ 1999-05-31 21:36     ` Joe Buck
  1 sibling, 0 replies; 14+ messages in thread
From: Joe Buck @ 1999-05-31 21:36 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: lind0753, egcs

> On May 18, 1999, "Stephen Lindholm" <lind0753@umn.edu> wrote:
> 
> > 1)  The new operators "or" "and" "not" (etc), described on Stroustrup C++PL
> > 3rd ed. p. 829 appear to not exist in egcs, or to be turned off by default.
> 
> Indeed.  Use -foperator-names or -ansi.  I think it is not enabled by
> default for fear of breaking header-files that still use them.  Maybe
> it's time to turn them on by default, now that we're moving to more
> strict ISO C++.

I don't think we should change it for 2.95; we can try flipping the
default afterwards, leaving the option as -fno-operator-names, in
snapshots and see how bad the damage is.

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

* Re: Peculiar functionality
  1999-06-02 17:52 Mike Stump
  1999-06-02 18:11 ` Joe Buck
@ 1999-06-30 15:43 ` Mike Stump
  1 sibling, 0 replies; 14+ messages in thread
From: Mike Stump @ 1999-06-30 15:43 UTC (permalink / raw)
  To: jbuck, lind0753; +Cc: egcs

> From: Joe Buck <jbuck@Synopsys.COM>
> Date: Tue, 18 May 99 17:44:53 PDT

> > 1) The new operators "or" "and" "not" (etc), described on
> > Stroustrup C++PL 3rd ed. p. 829 appear to not exist in egcs, or to
> > be turned off by default.

> These are enabled by the flag -foperator-names, or -ansi.  The reason for
> not making them the default is that too much old C++ code breaks.

We might want to experiement more with them on after 2.95, and before
3.0.

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

* Re: Peculiar functionality
  1999-06-02 18:11 ` Joe Buck
@ 1999-06-30 15:43   ` Joe Buck
  0 siblings, 0 replies; 14+ messages in thread
From: Joe Buck @ 1999-06-30 15:43 UTC (permalink / raw)
  To: Mike Stump; +Cc: jbuck, lind0753, egcs

[ -foperator_names ]
> > These are enabled by the flag -foperator-names, or -ansi.  The reason for
> > not making them the default is that too much old C++ code breaks.
> 
> We might want to experiement more with them on after 2.95, and before
> 3.0.

I suspect that lots of fixincludes work will be needed, to get rid of
keywords in header files.


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

* Re: Peculiar functionality
  1999-06-02 17:52 Mike Stump
@ 1999-06-02 18:11 ` Joe Buck
  1999-06-30 15:43   ` Joe Buck
  1999-06-30 15:43 ` Mike Stump
  1 sibling, 1 reply; 14+ messages in thread
From: Joe Buck @ 1999-06-02 18:11 UTC (permalink / raw)
  To: Mike Stump; +Cc: jbuck, lind0753, egcs

[ -foperator_names ]
> > These are enabled by the flag -foperator-names, or -ansi.  The reason for
> > not making them the default is that too much old C++ code breaks.
> 
> We might want to experiement more with them on after 2.95, and before
> 3.0.

I suspect that lots of fixincludes work will be needed, to get rid of
keywords in header files.


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

* Re: Peculiar functionality
@ 1999-06-02 17:52 Mike Stump
  1999-06-02 18:11 ` Joe Buck
  1999-06-30 15:43 ` Mike Stump
  0 siblings, 2 replies; 14+ messages in thread
From: Mike Stump @ 1999-06-02 17:52 UTC (permalink / raw)
  To: jbuck, lind0753; +Cc: egcs

> From: Joe Buck <jbuck@Synopsys.COM>
> Date: Tue, 18 May 99 17:44:53 PDT

> > 1) The new operators "or" "and" "not" (etc), described on
> > Stroustrup C++PL 3rd ed. p. 829 appear to not exist in egcs, or to
> > be turned off by default.

> These are enabled by the flag -foperator-names, or -ansi.  The reason for
> not making them the default is that too much old C++ code breaks.

We might want to experiement more with them on after 2.95, and before
3.0.

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

end of thread, other threads:[~1999-06-30 15:43 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-18 17:32 Peculiar functionality Stephen Lindholm
1999-05-18 17:45 ` Joe Buck
1999-05-31 21:36   ` Joe Buck
1999-05-18 18:13 ` Alexandre Oliva
1999-05-18 19:13   ` Joe Buck
1999-05-18 19:26     ` Alexandre Oliva
1999-05-31 21:36       ` Alexandre Oliva
1999-05-31 21:36     ` Joe Buck
1999-05-31 21:36   ` Alexandre Oliva
1999-05-31 21:36 ` Stephen Lindholm
1999-06-02 17:52 Mike Stump
1999-06-02 18:11 ` Joe Buck
1999-06-30 15:43   ` Joe Buck
1999-06-30 15:43 ` Mike Stump

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