public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/22343] New: Override overloaded function problems
@ 2005-07-07 10:07 gadniomaina at yahoo dot com
  2005-07-07 11:29 ` [Bug c++/22343] " gadniomaina at yahoo dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: gadniomaina at yahoo dot com @ 2005-07-07 10:07 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2863 bytes --]

/*
[gadnio@apocalypse]:[test]$ g++ -v -save-temps a.cpp
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib --enable-nls
--without-included-gettext --enable-threads=posix --program-suffix=-4.0
--enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr
--disable-werror --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.1 20050701 (prerelease) (Debian 4.0.0-12)
 /usr/lib/gcc/i486-linux-gnu/4.0.1/cc1plus -E -quiet -v -D_GNU_SOURCE a.cpp
-mtune=i486 -fpch-preprocess -o a.ii
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux-gnu/4.0.1/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i486-linux-gnu/4.0.1/../../../../include/c++/4.0.1
 /usr/lib/gcc/i486-linux-gnu/4.0.1/../../../../include/c++/4.0.1/i486-linux-gnu
 /usr/lib/gcc/i486-linux-gnu/4.0.1/../../../../include/c++/4.0.1/backward
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.0.1/include
 /usr/include
End of search list.
 /usr/lib/gcc/i486-linux-gnu/4.0.1/cc1plus -fpreprocessed a.ii -quiet -dumpbase
a.cpp -mtune=i486 -auxbase a -version -o a.s
GNU C++ version 4.0.1 20050701 (prerelease) (Debian 4.0.0-12) (i486-linux-gnu)
        compiled by GNU C version 4.0.1 20050701 (prerelease) (Debian 4.0.0-12).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64540
a.cpp: In function ‘int main()’:
a.cpp:24: error: invalid conversion from ‘const char*’ to ‘int’
a.cpp:24: error:   initializing argument 1 of ‘virtual void b::bb(int)’

*/
## Hello, i wonder why the following code does not work:
##--- copy here ---
# 1 "a.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "a.cpp"
class a
{
 public:
  virtual void bb( int )
  {
  }

  void bb( const char * )
  {
  }
};

class b: public a
{
 public:
  void bb( int )
  {
  }
};

int main()
{
    b bb;
    bb.bb( "" );
    return 0;
}
##--- copy here ---

-- 
           Summary: Override overloaded function problems
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gadniomaina at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: linux debian 3.0
  GCC host triplet: linux
GCC target triplet: linux debian 3.0


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


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

* [Bug c++/22343] Override overloaded function problems
  2005-07-07 10:07 [Bug c++/22343] New: Override overloaded function problems gadniomaina at yahoo dot com
@ 2005-07-07 11:29 ` gadniomaina at yahoo dot com
  2005-07-07 11:42 ` gadniomaina at yahoo dot com
  2005-07-07 13:11 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: gadniomaina at yahoo dot com @ 2005-07-07 11:29 UTC (permalink / raw)
  To: gcc-bugs



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


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


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

* [Bug c++/22343] Override overloaded function problems
  2005-07-07 10:07 [Bug c++/22343] New: Override overloaded function problems gadniomaina at yahoo dot com
  2005-07-07 11:29 ` [Bug c++/22343] " gadniomaina at yahoo dot com
@ 2005-07-07 11:42 ` gadniomaina at yahoo dot com
  2005-07-07 13:11 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: gadniomaina at yahoo dot com @ 2005-07-07 11:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gadniomaina at yahoo dot com  2005-07-07 11:42 -------
The compiler always gives an error when it cannot cast the parameter to the type
of the OVERLOADED function. for example, the code
class a
{
 public:
  virtual void bb( unsigned )
  {
  }

  void bb( int )
  {
  }
};

class b: public a
{
 public:
  void bb( unsigned )
  {
  }
};

int main()
{
    b bb;
    bb.bb( -5 );
    return 0;
}
compiles with a warning, but the code:
class a
{
 public:
  virtual void bb( unsigned )
  {
  }

  void bb( pair< int, double> )
  {
  }
};

class b: public a
{
 public:
  void bb( unsigned )
  {
  }
};

int main()
{
    b bb;
    pair< int, double > t;
    bb.bb( t );
    return 0;
}

does NOT compile at all.


-- 


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


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

* [Bug c++/22343] Override overloaded function problems
  2005-07-07 10:07 [Bug c++/22343] New: Override overloaded function problems gadniomaina at yahoo dot com
  2005-07-07 11:29 ` [Bug c++/22343] " gadniomaina at yahoo dot com
  2005-07-07 11:42 ` gadniomaina at yahoo dot com
@ 2005-07-07 13:11 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-07 13:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-07 13:11 -------
This is how C++ works.

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


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


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

end of thread, other threads:[~2005-07-07 13:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-07 10:07 [Bug c++/22343] New: Override overloaded function problems gadniomaina at yahoo dot com
2005-07-07 11:29 ` [Bug c++/22343] " gadniomaina at yahoo dot com
2005-07-07 11:42 ` gadniomaina at yahoo dot com
2005-07-07 13:11 ` 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).