Article View: gnu.gcc.bug
Article #173WRONG LIST (was: Re: Bugreport on GCC 2.2.2 running as C++ compiler...)
From: Mike Stump
Date: Tue, 21 Jul 1992 00:11
Date: Tue, 21 Jul 1992 00:11
100 lines
3226 bytes
3226 bytes
In the future please report all g++ bugs to the
bug-g++@prep.ai.mit.edu
list, thanks. If they are back-end bugs, they can be reported here,
but please let us know if you think the problem is in the back-end.
You don't need to resubmit this one.
> From: d9hh@dtek.chalmers.se
> Message-Id: <9207192148.AA09547@hacke0.dtek.chalmers.se>
> To: bug-gcc@prep.ai.mit.edu
> Date: Sun, 19 Jul 92 23:48:19 MET DST
> Hi, I think I've found a bug, even though I'm not a 100% sure, this is
> probably something you can figure out in a split second.
> Here we go...
> Version:
> GCC 2.1 and 2.2.2 (these are the versions I've seen the error (?) in).
> Running on machine:
> Some kind of Unix machine (GCC2.2.2), but I've also seen it on my Amiga and on
> a Sun (version 2.1)
> This is what I think is wrong:
> When compiling C++ programs: When assigning a function pointer to
> the adress of another function something in the type checking fails.
> Ok to see it clearly here are some sourcecodes:
> file one (C++)
> --------------
> // Yeah I know I should use iostream.h instead, but I'm trying to
> // make a point here that's all...
> #include "stdio.h"
> void foo(int&);
> void (*bar)(char);
> main() {
> int e = 34;
> bar = &foo; // *** Compiler should complain here
> bar(e); // ...booom!!
> }
> void foo(int& a) {
> printf("output: %d\n",a);
> }
> EOF
> file two (still C++)
> --------------------
> #include "stdio.h"
> void foo(int*);
> void (*bar)(char);
> main() {
> int e = 34;
> bar = &foo; // **** Compiler should complain here
> bar(e);
> }
> void foo(int* a) {
> printf("output: %d\n",*a);
> }
> EOF
> Ok. when compiling these two files doing 'gcc file1.cc' or
> 'gcc file2.cc' the compiler says nothing at all about the difference in
> type for bar and foo. See? bar takes a char and foo takes an int reference
> or in file two, an int pointer, still, the compiler says nothing at all.
> When running the programs, all I get is 'bus error' or 'segmentation
> fault'... (Or a nice crash on my Amiga.. :-).
> Trying to compile with 'gcc -ansi -pedantic -Wall' makes no difference.
> When trying to compile the same thing on CC instead, the compiler
> says this is clearly an error. The most interesting thing, though
> that kind of convinces me is that when compiling file two as plain C
> (which it is) GCC gives a warning about 'assignment from incompatible
> pointer type'.
> Hope this helps. And thanks for providing the world with the best
> compiler ever!
> --
> Henrik Harmsen Internet: d9hh@dtek.chalmers.se
> Chalmers University of Technology, Sweden.
> "I haven't lost my mind -- it's backed up on tape somewhere."
Technical Details
Message-ID:
<9207210011.AA12785@cygnus.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cygnus.com!mrsShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cygnus.com!mrs From: mrs@cygnus.com (Mike Stump) Subject: WRONG LIST (was: Re: Bugreport on GCC 2.2.2 running as C++ compiler...) Message-ID: <9207210011.AA12785@cygnus.com> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Tue, 21 Jul 1992 00:11:44 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 103