public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "greifel at megatop200 dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/29188]  New: accepts-invalid ambiguous between conversion function/constructor. related to const
Date: Fri, 22 Sep 2006 23:46:00 -0000	[thread overview]
Message-ID: <bug-29188-13286@http.gcc.gnu.org/bugzilla/> (raw)

g++ release 4.1.1 compiles the following invalid code without detecting an
error.
It does correctly find the error with -pedantic. Interestingly (perhaps), it
also correctly detects the ambiguous call where the argument involved is const
- as demonstrated by the second compilation below with the macro C2 defined:

sjh@mill:~/c++/compiler$ g++ -c conversion.ambig.c
sjh@mill:~/c++/compiler$ cat conversion.ambig.c
class Source;

class Destination
{
public:
Destination() {}
Destination (const Source& source) {}
};

class Source
{
public:
Source() {}
operator Destination() const { return Destination();}
};

Source source;
Destination wolf =  source; // ambiguous

#ifdef C2
const Source source2;
Destination wolf2 =  source2; // ambiguous
#endif
sjh@mill:~/c++/compiler$ g++ -D C2 conversion.ambig.c
conversion.ambig.c:22: error: conversion from 'const Source' to 'Destination'
is ambiguous
conversion.ambig.c:14: note: candidates are: Source::operator Destination()
const
conversion.ambig.c:7: note:                 Destination::Destination(const
Source&)
sjh@mill:~/c++/compiler$
sjh@mill:~/c++/compiler$
sjh@mill:~/c++/compiler$ gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /home/sjh/gcc/gcc-4.1.1/configure
--prefix=/home/sjh/gcc/prefix/ --enable-languages=c,c++
Thread model: posix
gcc version 4.1.1
sjh@mill:~/c++/compiler$


-- 
           Summary: accepts-invalid ambiguous between conversion
                    function/constructor. related to const
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: greifel at megatop200 dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29188


             reply	other threads:[~2006-09-22 23:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-22 23:46 greifel at megatop200 dot com [this message]
2006-09-22 23:58 ` [Bug c++/29188] undocumented extension with " pinskia at gcc dot gnu dot org
2006-09-23 16:29 ` greifel at megatop200 dot com
2006-10-10  3:45 ` bangerth at dealii dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-29188-13286@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).