🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2581

number cast to pointer to structure

#2581
From: Ken Raeburn
Date: Sun, 30 Apr 1989 18:40
52 lines
1225 bytes
GCC version: 1.35, vax.

Input file:

    /*
     * foo
     */

    struct s1 {
	int s1_one;
	int s1_two;
    };

    struct s2 {
	int s2_one;
	struct s1 s2_s1;
	int s2_two;
    };

    struct s3 {
	int s3_one;
	int s3_two;
	struct s2 s3_s2;
    };

    #ifndef BUG
    struct s3 * FOO;
    #else
    #define FOO ((struct s3 *)0x3700)
    #endif

    #define BAR	(FOO->s3_s2)		/* struct s2	*/
    #define QUUX	(&(BAR))	/* struct s2 *	*/

    extern void *xxx;

    void foo () {
	xxx = &BAR.s2_s1;
	xxx = &QUUX->s2_s1;		/* line 35 */
    }

Output:

    % gcc -S quux.c -DBUG
    quux.c: In function foo:
    quux.c:35: structure has no member named `s2_s1'

The file compiles properly when BUG is not defined; as I read it,
shouldn't the type of FOO be the same?

-- Ken
Technical Details
Message-ID: <8904301840.AA01005@BILL-THE-CAT.MIT.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ATHENA.MIT.EDU!raeburn

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ATHENA.MIT.EDU!raeburn
From: raeburn@ATHENA.MIT.EDU (Ken Raeburn)
Newsgroups: gnu.gcc.bug
Subject: number cast to pointer to structure
Message-ID: <8904301840.AA01005@BILL-THE-CAT.MIT.EDU>
Date: 30 Apr 89 18:40:15 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 52