public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17056] New: ambiguous function call problem
@ 2004-08-17  2:30 emild at collectivestudios dot com
  2004-08-17  3:13 ` [Bug c++/17056] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: emild at collectivestudios dot com @ 2004-08-17  2:30 UTC (permalink / raw)
  To: gcc-bugs

The following code should compile with no errors:

	template <class T>
	void foo( T const & );

	template <class T,int S>
	void foo( T (&)[S] );

	void bar( unsigned char const (&x)[16] )
		{
			foo(x);
		}

G++ incorrectly reports the following errors:

	In function `void bar(const unsigned char (&)[16])':
	error: call of overloaded `foo(const unsigned char[16])' is ambiguous
	error: candidates are: void foo(const T&) 
		[with T = unsigned char[16]]
	error:                 void foo(T (&)[S]) 
		[with T = const unsigned char, int S = 16]

Both Comeau C++ and VC 7.1 compile the code with no errors. Indeed, an 
instantiation of the second foo template with T=unsigned char const and S=16 is 
a perfect match for the call.

-- 
           Summary: ambiguous function call problem
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: emild at collectivestudios dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/17056] ambiguous function call problem
  2004-08-17  2:30 [Bug c++/17056] New: ambiguous function call problem emild at collectivestudios dot com
@ 2004-08-17  3:13 ` pinskia at gcc dot gnu dot org
  2004-08-18 15:33 ` [Bug c++/17056] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-17  3:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-17 03:13 -------
Hmm, I am starting to think both Comeau C++ and VC 7.1 are wrong as if you remove either one of 
the template functions the code is accepted  but then again ...

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid


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


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

* [Bug c++/17056] [3.3/3.4/3.5 Regression] ambiguous function call problem
  2004-08-17  2:30 [Bug c++/17056] New: ambiguous function call problem emild at collectivestudios dot com
  2004-08-17  3:13 ` [Bug c++/17056] " pinskia at gcc dot gnu dot org
@ 2004-08-18 15:33 ` pinskia at gcc dot gnu dot org
  2004-08-18 22:06 ` oliverst at online dot de
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-18 15:33 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |3.0.4 3.2.3 3.3.3 3.4.0
                   |                            |3.5.0
      Known to work|                            |2.95.3
            Summary|ambiguous function call     |[3.3/3.4/3.5 Regression]
                   |problem                     |ambiguous function call
                   |                            |problem
   Target Milestone|---                         |3.4.2


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


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

* [Bug c++/17056] [3.3/3.4/3.5 Regression] ambiguous function call problem
  2004-08-17  2:30 [Bug c++/17056] New: ambiguous function call problem emild at collectivestudios dot com
  2004-08-17  3:13 ` [Bug c++/17056] " pinskia at gcc dot gnu dot org
  2004-08-18 15:33 ` [Bug c++/17056] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
@ 2004-08-18 22:06 ` oliverst at online dot de
  2004-08-18 22:51 ` bangerth at dealii dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: oliverst at online dot de @ 2004-08-18 22:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From oliverst at online dot de  2004-08-18 22:06 -------
(In reply to comment #1)
> Hmm, I am starting to think both Comeau C++ and VC 7.1 are wrong as if you
remove either one of 
> the template functions the code is accepted  but then again ...

I don't know how VC 7.1 behaves, but VC 6 doesn't compile the templates until
they are actually used in the code. Gave me a hard time fixing all those yet
unused templates when porting from VC 6 code to GCC 3.2.x and GCC 3.4.x. Maybe
VC 7.1 still leaves the unused templates out of the compilation process.

-- 


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


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

* [Bug c++/17056] [3.3/3.4/3.5 Regression] ambiguous function call problem
  2004-08-17  2:30 [Bug c++/17056] New: ambiguous function call problem emild at collectivestudios dot com
                   ` (2 preceding siblings ...)
  2004-08-18 22:06 ` oliverst at online dot de
@ 2004-08-18 22:51 ` bangerth at dealii dot org
  2004-08-29 18:43 ` mmitchel at gcc dot gnu dot org
  2004-10-28  5:40 ` [Bug c++/17056] [3.3/3.4/4.0 " mmitchel at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-08-18 22:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-08-18 22:51 -------
Of course removing either template leaves the code compilable: both 
template functions are matches one way or other, so the code will 
compile. The question is what happens when both are present: is the 
call ambiguous as gcc thinks, or are there partial ordering rules that 
make it not ambiguous, as other compilers may think. 
 
I tend to believe the latter is the case, but lack the appropriate 
partial-ordering-qualifications to judge for sure. 
 
W. 

-- 


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


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

* [Bug c++/17056] [3.3/3.4/3.5 Regression] ambiguous function call problem
  2004-08-17  2:30 [Bug c++/17056] New: ambiguous function call problem emild at collectivestudios dot com
                   ` (3 preceding siblings ...)
  2004-08-18 22:51 ` bangerth at dealii dot org
@ 2004-08-29 18:43 ` mmitchel at gcc dot gnu dot org
  2004-10-28  5:40 ` [Bug c++/17056] [3.3/3.4/4.0 " mmitchel at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-08-29 18:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-08-29 18:43 -------
Postponed until GCC 3.4.3.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.2                       |3.4.3


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


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

* [Bug c++/17056] [3.3/3.4/4.0 Regression] ambiguous function call problem
  2004-08-17  2:30 [Bug c++/17056] New: ambiguous function call problem emild at collectivestudios dot com
                   ` (4 preceding siblings ...)
  2004-08-29 18:43 ` mmitchel at gcc dot gnu dot org
@ 2004-10-28  5:40 ` mmitchel at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-10-28  5:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-10-28 05:40 -------
This code is invalid; neither template is more specialized than the other.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nathan at codesourcery dot
                   |                            |com
             Status|UNCONFIRMED                 |RESOLVED
      Known to fail|3.0.4 3.2.3 3.3.3 3.4.0 4.0 |3.0.4 3.2.3 3.3.3 3.4.0
                   |                            |4.0.0
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2004-10-28  5:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-17  2:30 [Bug c++/17056] New: ambiguous function call problem emild at collectivestudios dot com
2004-08-17  3:13 ` [Bug c++/17056] " pinskia at gcc dot gnu dot org
2004-08-18 15:33 ` [Bug c++/17056] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
2004-08-18 22:06 ` oliverst at online dot de
2004-08-18 22:51 ` bangerth at dealii dot org
2004-08-29 18:43 ` mmitchel at gcc dot gnu dot org
2004-10-28  5:40 ` [Bug c++/17056] [3.3/3.4/4.0 " mmitchel at gcc dot gnu 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).