public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/29188]  New: accepts-invalid ambiguous between conversion function/constructor. related to const
@ 2006-09-22 23:46 greifel at megatop200 dot com
  2006-09-22 23:58 ` [Bug c++/29188] undocumented extension with " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: greifel at megatop200 dot com @ 2006-09-22 23:46 UTC (permalink / raw)
  To: gcc-bugs

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


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

* [Bug c++/29188] undocumented extension with ambiguous between conversion function/constructor. related to const
  2006-09-22 23:46 [Bug c++/29188] New: accepts-invalid ambiguous between conversion function/constructor. related to const greifel at megatop200 dot com
@ 2006-09-22 23:58 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-22 23:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-09-22 23:58 -------
I changed the summary since this is undocumented extension and we reject it
with -pedantic already, I don't know if this is useful extension or not.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |2.95.3 3.0.4 4.0.0 4.1.0


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


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

* [Bug c++/29188] undocumented extension with ambiguous between conversion function/constructor. related to const
  2006-09-22 23:46 [Bug c++/29188] New: accepts-invalid ambiguous between conversion function/constructor. related to const greifel at megatop200 dot com
  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
  2 siblings, 0 replies; 4+ messages in thread
From: greifel at megatop200 dot com @ 2006-09-23 16:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from greifel at megatop200 dot com  2006-09-23 16:29 -------
According to 1.4/8 implementations with extensions are required to "diagnose
programs that use extensions that are ill-formed according to this
International
Standard." This code is ill-formed so presumably g++ should print a warning.

I don't know the motivation for the extension but would highlight the question
of
whether it was intentional that it affects non-const arguments but not const.


-- 


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


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

* [Bug c++/29188] undocumented extension with ambiguous between conversion function/constructor. related to const
  2006-09-22 23:46 [Bug c++/29188] New: accepts-invalid ambiguous between conversion function/constructor. related to const greifel at megatop200 dot com
  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
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2006-10-10  3:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from bangerth at dealii dot org  2006-10-10 03:44 -------
Confirmed. Not a useful extension because confusing:
-----------------
struct A;

struct B {
    B (const A&);
};

struct A {
    operator B() const;
};

A a;
B b1 =  a;    // xpass
-----------------------
g/x> /home/bangerth/bin/gcc-4.2-pre/bin/c++ -c x.cc
g/x> /home/bangerth/bin/gcc-4.2-pre/bin/c++ -c x.cc -pedantic
x.cc:12: error: conversion from ‘A’ to ‘B’ is ambiguous
x.cc:8: note: candidates are: A::operator B() const
x.cc:4: note:                 B::B(const A&)


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at dealii dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-10-10 03:44:52
               date|                            |


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


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

end of thread, other threads:[~2006-10-10  3:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-22 23:46 [Bug c++/29188] New: accepts-invalid ambiguous between conversion function/constructor. related to const greifel at megatop200 dot com
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

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