public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "Martin v. Loewis" <martin AT mira.isdn.cs.tu-berlin.de>
To: stefan_iesao AT recol.es
Cc: gcc-bugs AT gcc.gnu.org
Subject: Re: bug
Date: Mon, 13 Sep 1999 23:45:00 -0000	[thread overview]
Message-ID: <199909140639.IAA20456@mira.isdn.cs.tu-berlin.de> (raw)
In-Reply-To: <3.0.3.32.19990912141955.0068c7a8@correo.recol.es>

> i have a amdk6-2 3dnow! 400Mhz and i experienced problesm compiling my SuSE
> 6.0 kernel.
> make suddenly stops with several different errors.
> i also had problems with the processor under windows.
> when i slow the speed down to 300Mhz it works just fine!
> what could i do?

I think you should return the computer to the vendor, and have it
replaced with one that actually works.

> does the new version of gcc help?

Unlikely.

Regards,
Martin
>From martinATmira.isdn.cs.tu-berlin.de Mon Sep 13 23:45:00 1999
From: "Martin v. Loewis" <martin AT mira.isdn.cs.tu-berlin.de>
To: andrew.bell AT bigfoot.com
Cc: bug-gcc AT gcc.gnu.org
Subject: Re: Virtual Mem Func Ptr Call Fails When Base Class Has No Vtable
Date: Mon, 13 Sep 1999 23:45:00 -0000
Message-id: <199909140637.IAA20455@mira.isdn.cs.tu-berlin.de>
References: <99091108362702.28114@bellfarm>
X-SW-Source: 1999-09/msg00378.html
Content-length: 860

> The following causes various faults (I've seen SEGV, BUS, ILL) on my system. 
> If the function Sub::test is non-virtual, or Base contains some virtual
> function, all is fine:

Thanks for your bug report. The bug is in your code, however: Without
the cast

   BaseMemCb cb = (BaseMemCb) &Sub::test;

g++ says (correctly)

a.cc: In function `int main()':
a.cc:21: converting `void (Sub::*)()' to `void (Base::*)()' is a contravariance violation
a.cc:21: conversion to `void (Base::*)()' from `void (Sub::*)()'
a.cc:21: type `Sub' is not a base type for type `Base'
a.cc:21:    in pointer to member conversion

Please see your C++ book on why this cast is invalid.

Strictly speaking, this is a reinterpret_cast; using the pointer
results in undefined behaviour. g++ choses to crash the code, which is
conforming to the C++ standard.

Hope this helps,
Martin
>From martinATmira.isdn.cs.tu-berlin.de Mon Sep 13 23:51:00 1999
From: "Martin v. Loewis" <martin AT mira.isdn.cs.tu-berlin.de>
To: oliva AT lsd.ic.unicamp.br
Cc: Stefan.Eilemann AT simpack.de, bug-gcc AT gnu.org
Subject: Re: Internal compiler error
Date: Mon, 13 Sep 1999 23:51:00 -0000
Message-id: <199909140648.IAA20509@mira.isdn.cs.tu-berlin.de>
References: <XFMail.990913124632.Stefan.Eilemann@simpack.de> <199909140627.IAA20402@mira.isdn.cs.tu-berlin.de> <orn1uq9eu9.fsf@cupuacu.lsd.ic.unicamp.br>
X-SW-Source: 1999-09/msg00379.html
Content-length: 310

> > without preprocessor output, there is not much we can do.
> 
> But there was an attachment with preprocessor output bzip2ed.

Yes, I was replying to the wrong report. On this report, I can't
comment much - it seems to be architecture specific, as I couldn't
reproduce it on i386.

Sorry about that,
Martin
>From olivaATlsd.ic.unicamp.br Tue Sep 14 00:03:00 1999
From: Alexandre Oliva <oliva AT lsd.ic.unicamp.br>
To: "Martin v. Loewis" <martin AT mira.isdn.cs.tu-berlin.de>
Cc: andrew.bell AT bigfoot.com, bug-gcc AT gcc.gnu.org
Subject: Re: Virtual Mem Func Ptr Call Fails When Base Class Has No Vtable
Date: Tue, 14 Sep 1999 00:03:00 -0000
Message-id: <oriu5e9dqq.fsf@cupuacu.lsd.ic.unicamp.br>
References: <99091108362702.28114@bellfarm> <199909140637.IAA20455@mira.isdn.cs.tu-berlin.de>
X-SW-Source: 1999-09/msg00380.html
Content-length: 2111

On Sep 14, 1999, "Martin v. Loewis" <martin@mira.isdn.cs.tu-berlin.de> wrote:

> Without the cast

>    BaseMemCb cb = (BaseMemCb) &Sub::test;

> g++ says (correctly)

> a.cc:21: converting `void (Sub::*)()' to `void (Base::*)()' is a contravariance violation

> Please see your C++ book on why this cast is invalid.

Err...  The C++ Standard says [expr.static.cast]:

9 An rvalue of type "pointer to member of D of type cv1 T" can  be  con-
  verted  to  an  rvalue of type "pointer to member of B of type cv2 T",
  where B is a base class (clause _class.derived_)  of  D,  if  a  valid
  standard  conversion  from  "pointer  to  member  of  B  of type T" to
  "pointer to member of D of type T" exists (_conv.mem_), and cv2 is the
  same cv-qualification as, or greater  cv-qualification  than,  cv1.11)
  The  null  member  pointer value (_conv.mem_) is converted to the null
  member pointer value of the destination type.  If class B contains the
  original member, or is a base or derived class of the class containing
  the original member, the resulting pointer to  member  points  to  the
  original  member.   Otherwise,  the  result  of the cast is undefined.
  [Note: although class B need not  contain  the  original  member,  the
  dynamic  type of the object on which the pointer to member is derefer-
  enced must contain the original member; see _expr.mptr.oper_.  ]

Since the class B is a base of the class containing the original
member, the old-style cast should succeed as a static_cast, and should
not invoke undefined behavior.


I seem to recall some wording in the Standard (or some earlier WP)
that would make the *use* of this pointer-to-member undefined unless
it was declared as virtual in the case class, but I can't find it any
more.  Can anybody?  Or was it removed, and the code should work?

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{dcc.unicamp.br,guarana.{org,com}} aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them


  reply	other threads:[~1999-09-13 23:45 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-12  5:21 bug Stefan Wehner
1999-09-13 23:45 ` Martin v. Loewis [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-02-08 18:07 bug Cseke Tamas
2006-07-19 18:57 bug kfahoo
2006-01-06 12:01 Bug Cavit Cahit VURAL
2005-12-18 12:14 bug Igor Selitsky
2005-03-03 12:15 Bug Administrator
2005-02-20 15:28 Bug Fikret Skrgic
2005-02-20 15:50 ` Bug Eric Botcazou
2002-07-30 14:56 bug Scott Dorsey
2002-01-08 17:46 bug ditty
2001-12-28 10:14 bug Paolo Carlini
2001-12-28  9:54 bug fabiosmoker
2001-12-11 12:14 BUG Jason Beltrame
2001-10-22 20:55 Bug Bob Bomar
2001-09-19 15:56 bug Yves Dorfsman
2001-07-02 17:07 bug NOBUHIRO OKAMOTO
2001-07-02 17:58 ` bug Toshi Morita
     [not found] <000d01c01bcf$94785c30$e20f083d@wildcomm.net>
2000-09-11 20:51 ` Bug Alexandre Oliva
2000-08-17 23:31 bug Thomas Rudlof
2000-08-11 10:46 bug Joseph Meeks
2000-07-05 15:10 bug Jesus Ruiz
2000-07-05 15:20 ` bug Alexandre Oliva
2000-04-20  6:04 bug BRODIER Olivier
2000-03-31 15:26 BUG David
     [not found] <4.3.0.20000307111239.00aaea40@mail.questgate.net>
2000-03-07 12:05 ` bug Martin v. Loewis
2000-03-08  8:14   ` bug Michael Long
2000-03-09 16:33     ` bug Alexandre Oliva
2000-02-29 10:57 bug wieland Kroetz
     [not found] <3896F92C.87F1A9FF@godel.dis.eafit.edu.co>
2000-02-01 19:32 ` BUG Alexandre Oliva
1999-12-06 12:45 Bug George Christakis
1999-12-31 20:54 ` Bug Brian Ford
1999-11-30 23:39 bug martin.schindelin
1999-11-30 23:39 ` bug Martin v. Loewis
1999-11-30 23:39 bug Martin Richard
1999-11-09 21:32 ` bug Alexandre Oliva
1999-10-31 23:03 bug Mike Stump
1999-10-26 11:02 Bug Gustavo Niemeyer
1999-10-27 12:34 ` Bug Martin v. Loewis
1999-10-19  9:51 bug Helen Sun
1999-09-10 19:53 Bug Samy
1999-09-10 23:48 ` Bug Mumit Khan
1999-07-31 23:33 bug John Cotton
1999-08-31 22:45 ` bug Jeffrey A Law
1999-07-31 23:33 bug Wael Hassan
1999-07-31 23:33 ` bug Brian Ford
1999-06-30 23:07 BUG root of all evil
1999-06-05  2:46 ` BUG Alexandre Oliva
1999-06-28  5:34 BUG Stelios Xanthakis
1999-06-29  1:34 ` BUG Alexandre Oliva
1999-06-18 11:51 bug Mohamed Zaakoun
1999-05-31 21:06 Bug Klaus Causemann
1999-05-22  1:41 ` Bug Philipp Thomas
     [not found] <99051319112100.00451@localhost.localdomain>
1999-05-31 21:06 ` Bug Martin v. Loewis
1999-04-30 23:15 BUG Chris Teli
1999-04-15  7:09 ` BUG Alexandre Oliva
1999-04-30 23:15 Bug David Corbin
1999-04-30 23:15 bug holger
1999-04-13 18:26 BUG Steven Chi
1999-04-30 23:15 ` BUG Alexandre Oliva
1999-04-04  8:53 Bug Mathias Creutz
1999-04-05 12:40 ` Bug Alexandre Oliva
1999-02-28 23:30 Bug Philip Rademakers
1999-02-28 23:30 ` Bug Nathan Sidwell
1999-02-04  6:49 Bug Dan Vasaru
1998-12-17  8:25 bug Jean-Benoit Pierrot
1998-11-23  6:46 bug Massimo Boninsegni
1998-11-23 13:26 ` bug Alexandre Oliva
1998-09-23  7:09 Bug Energoprom
1998-09-23 22:02 ` Bug Alexandre Oliva
1998-09-17  5:09 bug Thien Traitham
1998-09-17 10:49 ` bug Alexandre Oliva
1998-08-31 13:07 bug Brian Grossman
1998-09-01 20:17 ` bug Alexandre Oliva
1998-07-28  4:13 bug Henning Emmrich
1998-07-17  9:51 Bug J. de Antonio
1998-07-14 17:29 bug Fritz Koenig
1998-07-14 23:27 ` bug Martin von Loewis
1998-04-21 12:00 bug root
1998-03-23 23:23 bug Mats Hjelm
1998-02-09 23:36 bug Leeann Bent

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199909140639.IAA20456@mira.isdn.cs.tu-berlin.de \
    --to=gcc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).