public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Const in default function arguments?
@ 2003-04-04 18:10 Eric Lemings
  2003-04-04 19:59 ` John Love-Jensen
  2003-04-05 16:24 ` LLeweLLyn Reese
  0 siblings, 2 replies; 9+ messages in thread
From: Eric Lemings @ 2003-04-04 18:10 UTC (permalink / raw)
  To: eljay, eric, gcc-help

void foo (int i) {
  ++i;
}

This function foo doesn't make sense either but it's not a
compile error.  Just because something doesn't make sense
doesn't mean it's illegal.  Sounds like the non-const
parameter should be a warning, not an error.

An error means that it's illegal and the standard defines
what is legal and what is not.  Can somebody not point to
the standard that says you can't use a default function
argument for a non-const parameter?

Thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: Const in default function arguments?
@ 2003-04-05 11:30 Eric Lemings
  2003-04-05 12:24 ` Nathan Sidwell
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Lemings @ 2003-04-05 11:30 UTC (permalink / raw)
  To: eljay, nathan; +Cc: gcc-help

That's a bit different.  The type of the default argument here
is T&.  In the original post, the type is T.

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: Const in default function arguments?
@ 2003-04-04 20:12 Eric Lemings
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Lemings @ 2003-04-04 20:12 UTC (permalink / raw)
  To: elemings, eljay, eric, gcc-help

That's good enough for me.  Thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Const in default function arguments?
@ 2003-04-03 22:10 Eric Lemings
  2003-04-04 12:32 ` John Love-Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Lemings @ 2003-04-03 22:10 UTC (permalink / raw)
  To: gcc-help

[elemings@cyberia c++]$ g++ --version
g++ (GCC) 3.2.2
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[elemings@cyberia c++]$ more Test01.cpp

#include <iostream>

struct Foo {
  int i;
};

struct Bar: public Foo {
  // empty class body
};

void G (const Foo& f = Bar ()) {
  std::cout << f.i << std::endl;
}

[elemings@cyberia c++]$ diff Test01.cpp Test02.cpp
12c12
< void G (const Foo& f = Bar ()) {
---
> void G (Foo& f = Bar ()) {
[elemings@cyberia c++]$ g++ -g -Wall -pedantic -c Test01.cpp
[elemings@cyberia c++]$ g++ -g -Wall -pedantic -c Test02.cpp
Test02.cpp:12: default argument for `Foo&f' has type `Bar'

Why won't the non-const version compile?

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

end of thread, other threads:[~2003-04-05 16:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-04 18:10 Const in default function arguments? Eric Lemings
2003-04-04 19:59 ` John Love-Jensen
2003-04-05 10:27   ` Nathan Sidwell
2003-04-05 16:24 ` LLeweLLyn Reese
  -- strict thread matches above, loose matches on Subject: below --
2003-04-05 11:30 Eric Lemings
2003-04-05 12:24 ` Nathan Sidwell
2003-04-04 20:12 Eric Lemings
2003-04-03 22:10 Eric Lemings
2003-04-04 12:32 ` John Love-Jensen

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