public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/27775]  New: incorrect "ambiguous" error message with multiple inheritance and nested class.
@ 2006-05-26 22:50 rnewman at compubrite dot com
  2006-08-06 22:19 ` [Bug c++/27775] " bangerth at dealii dot org
  2008-08-10  9:50 ` kristian dot spangsege at gmail dot com
  0 siblings, 2 replies; 6+ messages in thread
From: rnewman at compubrite dot com @ 2006-05-26 22:50 UTC (permalink / raw)
  To: gcc-bugs

The test-case:

// testcase: -------------------------
struct A
{
    struct B
    {
    };
};

struct C : A, A::B
{
    void foo(B b);
    void bar(B* pb);
};
//------------------------------------
==============
The error:
foo.cc:11: error: reference to 'B' is ambiguous
foo.cc:5: error: candidates are: struct A::B
foo.cc:5: error:                 struct A::B
foo.cc:11: error: 'B' has not been declared
foo.cc:12: error: reference to 'B' is ambiguous
foo.cc:5: error: candidates are: struct A::B
foo.cc:5: error:                 struct A::B
foo.cc:12: error: 'B' has not been declared

-------------
There is only one type "B", whether it's referred to as ::A::B, (from the
global scope), or "A::B", injected from the first inheritance, or simpy "B"
injected from the second.  These all refer to the same type.  There is no
ambiguity.

Note, GCC accepts this if the "foo" member functions are delcared w/ namespace
qualification.  For example, this code is accepted:

struct C : A, A::B
{
    void foo(A::B b);
    void bar(A::B* pb);
};
=================
This behaviour is found in the following versions of GCC:
egcs-2.91.66, gcc-3.2, gcc-3.3, gcc-3.4.3, gcc-3.4.6, gcc-4.0
I haven't tried other versions.


-- 
           Summary: incorrect "ambiguous" error message with multiple
                    inheritance and nested class.
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rnewman at compubrite dot com


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


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

* [Bug c++/27775] incorrect "ambiguous" error message with multiple inheritance and nested class.
  2006-05-26 22:50 [Bug c++/27775] New: incorrect "ambiguous" error message with multiple inheritance and nested class rnewman at compubrite dot com
@ 2006-08-06 22:19 ` bangerth at dealii dot org
  2008-08-10  9:50 ` kristian dot spangsege at gmail dot com
  1 sibling, 0 replies; 6+ messages in thread
From: bangerth at dealii dot org @ 2006-08-06 22:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bangerth at dealii dot org  2006-08-06 22:19 -------
Confirmed. To make things worse, the diagnostic is really longish
right now as well:

g/x> c++ -c x.cc
x.cc:10: error: reference to 'B' is ambiguous
x.cc:4: error: candidates are: struct A::B
x.cc:4: error:                 struct A::B
x.cc:10: error: reference to 'B' is ambiguous
x.cc:4: error: candidates are: struct A::B
x.cc:4: error:                 struct A::B
x.cc:10: error: 'B' has not been declared
x.cc:11: error: reference to 'B' is ambiguous
x.cc:4: error: candidates are: struct A::B
x.cc:4: error:                 struct A::B
x.cc:11: error: reference to 'B' is ambiguous
x.cc:4: error: candidates are: struct A::B
x.cc:4: error:                 struct A::B
x.cc:11: error: 'B' has not been declared

The 'is ambiguous' message is apparently printed twice, and the 'has not 
been declared' message is, and has long been, bogus...

W.


-- 

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-08-06 22:19:48
               date|                            |


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


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

* [Bug c++/27775] incorrect "ambiguous" error message with multiple inheritance and nested class.
  2006-05-26 22:50 [Bug c++/27775] New: incorrect "ambiguous" error message with multiple inheritance and nested class rnewman at compubrite dot com
  2006-08-06 22:19 ` [Bug c++/27775] " bangerth at dealii dot org
@ 2008-08-10  9:50 ` kristian dot spangsege at gmail dot com
  1 sibling, 0 replies; 6+ messages in thread
From: kristian dot spangsege at gmail dot com @ 2008-08-10  9:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from kristian dot spangsege at gmail dot com  2008-08-10 09:49 -------
I just confirmed this bug in GCC 4.3.0.


-- 


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


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

* [Bug c++/27775] incorrect "ambiguous" error message with multiple inheritance and nested class.
       [not found] <bug-27775-4@http.gcc.gnu.org/bugzilla/>
  2012-01-27 17:56 ` rnewman at compubrite dot com
  2012-01-28 20:50 ` manu at gcc dot gnu.org
@ 2021-07-27  2:44 ` rnewman at compubrite dot com
  2 siblings, 0 replies; 6+ messages in thread
From: rnewman at compubrite dot com @ 2021-07-27  2:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27775

--- Comment #5 from Rich Newman <rnewman at compubrite dot com> ---
(In reply to Manuel López-Ibáñez from comment #4)

> Clang 3.0 also reject this, so I am not sure whether is actually valid, but
> the repeated messages are suspicious.
> 

EDG accepts it, and I can see nothing wrong with the code according to the
standards.


The following versions of GCC also reject it with substantially similar error
messages:

10.1.0
11.1.0
5.4.0
6.3.0
7.1.0
7.4.0
8.1.0
8.3.0
9.1.0
9.2.0

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

* [Bug c++/27775] incorrect "ambiguous" error message with multiple inheritance and nested class.
       [not found] <bug-27775-4@http.gcc.gnu.org/bugzilla/>
  2012-01-27 17:56 ` rnewman at compubrite dot com
@ 2012-01-28 20:50 ` manu at gcc dot gnu.org
  2021-07-27  2:44 ` rnewman at compubrite dot com
  2 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu.org @ 2012-01-28 20:50 UTC (permalink / raw)
  To: gcc-bugs

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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-01-28 20:04:05 UTC ---
Also confirmed with GCC 4.7 rev 180166.

Clang 3.0 also reject this, so I am not sure whether is actually valid, but the
repeated messages are suspicious.

/tmp/webcompile/_9463_0.cc:10:14: error: member 'B' found in multiple base
classes of different types
    void foo(B b);
             ^
/tmp/webcompile/_9463_0.cc:3:12: note: member found by ambiguous name lookup
    struct B
           ^
/tmp/webcompile/_9463_0.cc:3:12: note: member found by ambiguous name lookup
/tmp/webcompile/_9463_0.cc:11:14: error: member 'B' found in multiple base
classes of different types
    void bar(B* pb);
             ^
/tmp/webcompile/_9463_0.cc:3:12: note: member found by ambiguous name lookup
    struct B
           ^
/tmp/webcompile/_9463_0.cc:3:12: note: member found by ambiguous name lookup
2 errors generated.


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

* [Bug c++/27775] incorrect "ambiguous" error message with multiple inheritance and nested class.
       [not found] <bug-27775-4@http.gcc.gnu.org/bugzilla/>
@ 2012-01-27 17:56 ` rnewman at compubrite dot com
  2012-01-28 20:50 ` manu at gcc dot gnu.org
  2021-07-27  2:44 ` rnewman at compubrite dot com
  2 siblings, 0 replies; 6+ messages in thread
From: rnewman at compubrite dot com @ 2012-01-27 17:56 UTC (permalink / raw)
  To: gcc-bugs

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

Rich Newman <rnewman at compubrite dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|4.0.0                       |4.5.1
      Known to fail|                            |4.3.0, 4.3.4, 4.4.4, 4.5.1

--- Comment #3 from Rich Newman <rnewman at compubrite dot com> 2012-01-27 17:12:13 UTC ---
Bug still in version 4.3.4:

$ g++ -c bug27775.cc
bug27775.cc:11: error: reference to 'B' is ambiguous
bug27775.cc:5: error: candidates are: struct A::B
bug27775.cc:5: error:                 struct A::B
bug27775.cc:11: error: reference to 'B' is ambiguous
bug27775.cc:5: error: candidates are: struct A::B
bug27775.cc:5: error:                 struct A::B
bug27775.cc:11: error: 'B' has not been declared
bug27775.cc:12: error: reference to 'B' is ambiguous
bug27775.cc:5: error: candidates are: struct A::B
bug27775.cc:5: error:                 struct A::B
bug27775.cc:12: error: reference to 'B' is ambiguous
bug27775.cc:5: error: candidates are: struct A::B
bug27775.cc:5: error:                 struct A::B
bug27775.cc:12: error: 'B' has not been declared
$ g++ -dumpversion
4.3.4

Also in version 4.4.4:
$ g++ -c bug27775.cc
bug27775.cc:11: error: reference to 'B' is ambiguous
bug27775.cc:5: error: candidates are: struct A::B
bug27775.cc:5: error:                 struct A::B
bug27775.cc:11: error: reference to 'B' is ambiguous
bug27775.cc:5: error: candidates are: struct A::B
bug27775.cc:5: error:                 struct A::B
bug27775.cc:11: error: 'B' has not been declared
bug27775.cc:12: error: reference to 'B' is ambiguous
bug27775.cc:5: error: candidates are: struct A::B
bug27775.cc:5: error:                 struct A::B
bug27775.cc:12: error: reference to 'B' is ambiguous
bug27775.cc:5: error: candidates are: struct A::B
bug27775.cc:5: error:                 struct A::B
bug27775.cc:12: error: 'B' has not been declared
$ g++ -dumpversion
4.4.4
$

Also in 4.5.1:

$ g++ -c bug27775.cc
bug27775.cc:11:14: error: reference to 'B' is ambiguous
bug27775.cc:5:5: error: candidates are: struct A::B A::B::B
bug27775.cc:5:5: error:                 struct A::B
bug27775.cc:11:14: error: 'B' has not been declared
bug27775.cc:12:14: error: reference to 'B' is ambiguous
bug27775.cc:5:5: error: candidates are: struct A::B A::B::B
bug27775.cc:5:5: error:                 struct A::B
bug27775.cc:12:14: error: 'B' has not been declared
$ g++ -dumpversion
4.5.1


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

end of thread, other threads:[~2021-07-27  2:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-26 22:50 [Bug c++/27775] New: incorrect "ambiguous" error message with multiple inheritance and nested class rnewman at compubrite dot com
2006-08-06 22:19 ` [Bug c++/27775] " bangerth at dealii dot org
2008-08-10  9:50 ` kristian dot spangsege at gmail dot com
     [not found] <bug-27775-4@http.gcc.gnu.org/bugzilla/>
2012-01-27 17:56 ` rnewman at compubrite dot com
2012-01-28 20:50 ` manu at gcc dot gnu.org
2021-07-27  2:44 ` rnewman at compubrite dot com

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