🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #265

invalid function refs generated

#265
From: Joe Linoff
Date: Tue, 14 Apr 1992 22:43
49 lines
1614 bytes
* VERSION: g++ version 2.1

* SOURCE FILE: problem.cc

    =======================================================================
    #include <stdio.h>

    typedef void (*fp_one_args)(const char*);
    typedef void (*fp_two_args)(const char*, const char*);

    struct callbackSpec {
	fp_one_args f1;
	fp_two_args f2;
    };

    static void callback1(const char*) {}
    static void callback2(const char*, const char*) {}

    callbackSpec bad = { &callback1, &callback2, };
    callbackSpec ok = { callback1, callback2, };

    int main() {
	printf(
	    "bad.f1 == 0x%x, bad.f2 == 0x%x, ok.f1 == 0x%x, ok.f2 == 0x%x\n",
	    bad.f1, bad.f2, ok.f1, ok.f2);
	return !(bad.f1 && bad.f2 && ok.f1 && ok.f2);
    }
    =======================================================================

* COMMAND ARGUMENTS:

	g++ -c -g problem.cc
	g++ -o problem problem.o

*  tm.h and md

	tm.h -> ./config/tm-sparc.h
	md -> ./config/sparc.md

* MACHINE TYPE and O/S

	SPARCstation 2
	4.1.1

* DESCRIPTION OF INCORRECT BEHAVIOR:

    The compiler generates bad address information for the bad variable.
    When I ran it the result was:
	bad.f1 == 0x0, bad.f2 == 0x0, ok.f1 == 0x2290, ok.f2 == 0x22a8
Technical Details
Message-ID: <9204142243.AA21754@dharna.crosscheck>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!dharna.UUCP!joe

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!dharna.UUCP!joe
From: joe@dharna.UUCP (Joe Linoff)
Subject: invalid function refs generated
Message-ID: <9204142243.AA21754@dharna.crosscheck>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 14 Apr 1992 22:43:04 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 51