public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/25278]  New: g++ seems to ignore an overloaded function.
@ 2005-12-06 17:37 theodore dot papadopoulo at sophia dot inria dot fr
  2005-12-06 17:39 ` [Bug c++/25278] " theodore dot papadopoulo at sophia dot inria dot fr
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: theodore dot papadopoulo at sophia dot inria dot fr @ 2005-12-06 17:37 UTC (permalink / raw)
  To: gcc-bugs

The code attached does not compile since version 4.0 of gcc.
Remove either the Cpu namespace or one element in the enumeration or replace
the array size in RGBPixel by a constant and the bug disappears.

It looks as if g++ ignores the overload for ChangeEndianness(RGB<T>&) when it
calls it from ChangeEndianness(T* begin,const T* end) so that the generic
version ChangeEndianness(T& t) is called instead generating and error because
the default class for SwapEndianness does not contain any swap method.

This has been tested with gcc version 4.2.0 20051206 (experimental).

Note also that things slightly improved since
gcc version 4.2.0 20051124 (experimental)
which failed also if the enumeration only had two elements (instead of three
now).

All this is a regression since gcc-3.4.


-- 
           Summary: g++ seems to ignore an overloaded function.
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: theodore dot papadopoulo at sophia dot inria dot fr
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c++/25278] g++ seems to ignore an overloaded function.
  2005-12-06 17:37 [Bug c++/25278] New: g++ seems to ignore an overloaded function theodore dot papadopoulo at sophia dot inria dot fr
@ 2005-12-06 17:39 ` theodore dot papadopoulo at sophia dot inria dot fr
  2005-12-06 17:48 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: theodore dot papadopoulo at sophia dot inria dot fr @ 2005-12-06 17:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from theodore dot papadopoulo at sophia dot inria dot fr  2005-12-06 17:39 -------
Created an attachment (id=10419)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10419&action=view)
The code describing the regression.

Simplify compile with g++


-- 


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


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

* [Bug c++/25278] g++ seems to ignore an overloaded function.
  2005-12-06 17:37 [Bug c++/25278] New: g++ seems to ignore an overloaded function theodore dot papadopoulo at sophia dot inria dot fr
  2005-12-06 17:39 ` [Bug c++/25278] " theodore dot papadopoulo at sophia dot inria dot fr
@ 2005-12-06 17:48 ` pinskia at gcc dot gnu dot org
  2005-12-06 18:46 ` theodore dot papadopoulo at sophia dot inria dot fr
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-12-06 17:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2005-12-06 17:48 -------
No, GCC is correct to reject this code.  What is happening is that the 
overloaded set for the ChangeEndianness in the second ChangeEndianness is only
the first and the second so there is no way to consider the third (and the one
which you want) to be called.

This is the correct standards demanding behavior.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug c++/25278] g++ seems to ignore an overloaded function.
  2005-12-06 17:37 [Bug c++/25278] New: g++ seems to ignore an overloaded function theodore dot papadopoulo at sophia dot inria dot fr
  2005-12-06 17:39 ` [Bug c++/25278] " theodore dot papadopoulo at sophia dot inria dot fr
  2005-12-06 17:48 ` pinskia at gcc dot gnu dot org
@ 2005-12-06 18:46 ` theodore dot papadopoulo at sophia dot inria dot fr
  2005-12-06 18:51 ` theodore dot papadopoulo at sophia dot inria dot fr
  2005-12-06 19:27 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: theodore dot papadopoulo at sophia dot inria dot fr @ 2005-12-06 18:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from theodore dot papadopoulo at sophia dot inria dot fr  2005-12-06 18:46 -------
(In reply to comment #0)
> The code attached does not compile since version 4.0 of gcc.
> Remove either the Cpu namespace or one element in the enumeration or replace
> the array size in RGBPixel by a constant and the bug disappears.
> 
> It looks as if g++ ignores the overload for ChangeEndianness(RGB<T>&) when it
> calls it from ChangeEndianness(T* begin,const T* end) so that the generic
> version ChangeEndianness(T& t) is called instead generating and error because
> the default class for SwapEndianness does not contain any swap method.
> 
> This has been tested with gcc version 4.2.0 20051206 (experimental).
> 
> Note also that things slightly improved since
> gcc version 4.2.0 20051124 (experimental)
> which failed also if the enumeration only had two elements (instead of three
> now).
> 
> All this is a regression since gcc-3.4.
> 


-- 

theodore dot papadopoulo at sophia dot inria dot fr changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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


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

* [Bug c++/25278] g++ seems to ignore an overloaded function.
  2005-12-06 17:37 [Bug c++/25278] New: g++ seems to ignore an overloaded function theodore dot papadopoulo at sophia dot inria dot fr
                   ` (2 preceding siblings ...)
  2005-12-06 18:46 ` theodore dot papadopoulo at sophia dot inria dot fr
@ 2005-12-06 18:51 ` theodore dot papadopoulo at sophia dot inria dot fr
  2005-12-06 19:27 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: theodore dot papadopoulo at sophia dot inria dot fr @ 2005-12-06 18:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from theodore dot papadopoulo at sophia dot inria dot fr  2005-12-06 18:51 -------
(In reply to comment #2)
I may accept that g++ is right to reject this code. I cannot convince myself
from reading the standard but I'm not a langage lawyer. I think that this is a
major flaw in C++ but that's another topic...

g++ cannot be right. Again remove one value from the enumeration, and the
compiler accepts the code. Maybe it accepts invalid code but that would still
be a bug. Similarly, remove one namespace and the code is accepted.

If those two behaviour are mandated by the standard, I'll change C++ for
something else immediately. THESE ARE IN A WAY OR AN ANOTHER G++ BUGS !!!


-- 


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


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

* [Bug c++/25278] g++ seems to ignore an overloaded function.
  2005-12-06 17:37 [Bug c++/25278] New: g++ seems to ignore an overloaded function theodore dot papadopoulo at sophia dot inria dot fr
                   ` (3 preceding siblings ...)
  2005-12-06 18:51 ` theodore dot papadopoulo at sophia dot inria dot fr
@ 2005-12-06 19:27 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-12-06 19:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2005-12-06 19:27 -------
The reason why removing one enum works is because the size of the RGB will be
one instead of two so that the specialized version of SwapEndianness::swap can
be used.  There is nothing magical here with respect with that.

EDG gives the same result too.

This was an accepts invalid code before 4.1.0 so closing as a dup of the
orginal bug about the accepts invalid (also this could be said to be wrong code
see the dup bug report for more information on how that is true).

*** This bug has been marked as a duplicate of 2922 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2005-12-06 19:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-06 17:37 [Bug c++/25278] New: g++ seems to ignore an overloaded function theodore dot papadopoulo at sophia dot inria dot fr
2005-12-06 17:39 ` [Bug c++/25278] " theodore dot papadopoulo at sophia dot inria dot fr
2005-12-06 17:48 ` pinskia at gcc dot gnu dot org
2005-12-06 18:46 ` theodore dot papadopoulo at sophia dot inria dot fr
2005-12-06 18:51 ` theodore dot papadopoulo at sophia dot inria dot fr
2005-12-06 19:27 ` pinskia 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).