public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51480] New: non-const default argument gets rejected
@ 2011-12-09 8:41 thomas@maier-komor.de
2011-12-09 9:36 ` [Bug c++/51480] " redi at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: thomas@maier-komor.de @ 2011-12-09 8:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51480
Bug #: 51480
Summary: non-const default argument gets rejected
Classification: Unclassified
Product: gcc
Version: 4.5.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: thomas@maier-komor.de
non-const default arguments get rejected with following error message:
error: default argument for 'A& a' has type 'A'
Here is an example, where function rejected causes an error, while function
accepted is accepted.
struct A
{
};
void accepted(const A &a = A())
{
}
void rejected(A &a = A())
{
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/51480] non-const default argument gets rejected
2011-12-09 8:41 [Bug c++/51480] New: non-const default argument gets rejected thomas@maier-komor.de
@ 2011-12-09 9:36 ` redi at gcc dot gnu.org
2011-12-09 9:52 ` thomas@maier-komor.de
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2011-12-09 9:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51480
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-12-09 09:34:28 UTC ---
(In reply to comment #0)
> void rejected(A &a = A())
You can't bind a non-const reference to a temporary
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/51480] non-const default argument gets rejected
2011-12-09 8:41 [Bug c++/51480] New: non-const default argument gets rejected thomas@maier-komor.de
2011-12-09 9:36 ` [Bug c++/51480] " redi at gcc dot gnu.org
@ 2011-12-09 9:52 ` thomas@maier-komor.de
2011-12-09 10:03 ` redi at gcc dot gnu.org
2011-12-09 11:23 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: thomas@maier-komor.de @ 2011-12-09 9:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51480
--- Comment #2 from Thomas Maier-Komor <thomas@maier-komor.de> 2011-12-09 09:47:06 UTC ---
Why is that so?
Visual Studio compiler seems to handle that situation without a problem and I
think it could come handy in certain situations...
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/51480] non-const default argument gets rejected
2011-12-09 8:41 [Bug c++/51480] New: non-const default argument gets rejected thomas@maier-komor.de
2011-12-09 9:36 ` [Bug c++/51480] " redi at gcc dot gnu.org
2011-12-09 9:52 ` thomas@maier-komor.de
@ 2011-12-09 10:03 ` redi at gcc dot gnu.org
2011-12-09 11:23 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2011-12-09 10:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51480
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-12-09 09:58:12 UTC ---
Visual Studio is not a real C++ compiler.
Try http://comeaucomputing.com/tryitout/ or http://llvm.org/demo/
Your code is not valid C++, sorry.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/51480] non-const default argument gets rejected
2011-12-09 8:41 [Bug c++/51480] New: non-const default argument gets rejected thomas@maier-komor.de
` (2 preceding siblings ...)
2011-12-09 10:03 ` redi at gcc dot gnu.org
@ 2011-12-09 11:23 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2011-12-09 11:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51480
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-12-09 10:02:52 UTC ---
If you think it's useful to modify an object that will never be used, you can
do it like this:
struct A
{
};
void accepted(const A &a = A())
{
}
void rejected(A &a)
{
}
void rejected()
{
A unused;
rejected(unused);
}
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-12-09 10:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-09 8:41 [Bug c++/51480] New: non-const default argument gets rejected thomas@maier-komor.de
2011-12-09 9:36 ` [Bug c++/51480] " redi at gcc dot gnu.org
2011-12-09 9:52 ` thomas@maier-komor.de
2011-12-09 10:03 ` redi at gcc dot gnu.org
2011-12-09 11:23 ` redi at gcc dot gnu.org
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).