public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: gkmohan@ece.arizona.edu
To: gcc-gnats@gcc.gnu.org
Subject: c++/8631: bug in typecasting the return value of a function
Date: Mon, 25 Nov 2002 08:46:00 -0000	[thread overview]
Message-ID: <20021119022405.19567.qmail@sources.redhat.com> (raw)


>Number:         8631
>Category:       c++
>Synopsis:       bug in typecasting the return value of a function
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 18 18:26:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     gkmohan@ece.arizona.edu
>Release:        unknown-1.0
>Organization:
>Environment:

>Description:
typecasting a function pointer to return different value seg faults or returns nonsense (depending on the version)

this is what g++ -v returns
-----------------------------------------------------
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-85)
-----------------------------------------------------

--file test.cc--
#include <iostream.h>
#include <complex.h>

#define CAST complex<double>

int f1( int x )
{
   return x;
}

void f2( CAST (*f)(int), int x )
{
   cout << (*f)(x);
}

main()
{
   f2( (CAST (*)(int)) &f1, 4 );
}
>How-To-Repeat:
g++ -o test test.cc
./test
>Fix:
:-< none
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2002-11-19  2:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-25  8:46 gkmohan [this message]
2002-11-25 15:13 bangerth

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=20021119022405.19567.qmail@sources.redhat.com \
    --to=gkmohan@ece.arizona.edu \
    --cc=gcc-gnats@gcc.gnu.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).