public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: other/1865: struct utsname members are different for g++ and gcc
@ 2002-03-31  2:27 rth
  0 siblings, 0 replies; 2+ messages in thread
From: rth @ 2002-03-31  2:27 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, jnance, nobody

Synopsis: struct utsname members are different for g++ and gcc

State-Changed-From-To: open->closed
State-Changed-By: rth
State-Changed-When: Sun Mar 31 02:27:46 2002
State-Changed-Why:
    Not a gcc bug.  Contact the glibc folk about this.
    See also -D_GNU_SOURCE.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=1865


^ permalink raw reply	[flat|nested] 2+ messages in thread

* other/1865: struct utsname members are different for g++ and gcc
@ 2001-04-01  0:00 jnance
  0 siblings, 0 replies; 2+ messages in thread
From: jnance @ 2001-04-01  0:00 UTC (permalink / raw)
  To: gcc-gnats

>Number:         1865
>Category:       other
>Synopsis:       struct utsname members are different for g++ and gcc
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 03 16:06:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     James Lewis Nance
>Release:        2.97 20010202 (experimental)
>Organization:
>Environment:
System: Linux bessie 2.4.1 #10 Tue Jan 30 22:06:40 EST 2001 i586 unknown
Architecture: i586

	
host: i586-pc-linux-gnu
build: i586-pc-linux-gnu
target: i586-pc-linux-gnu
configured with: ../gcc/configure --prefix=/usr/local/home/jlnance/gcctemp
>Description:
	The definition of struct utsname is different depending on on whether
	one uses gcc or g++ to compile the program:
	
	bessie> $HOME/gcctemp/bin/gcc -o /dev/null -c $HOME/y.c
	bessie> $HOME/gcctemp/bin/g++ -o /dev/null -c $HOME/y.c
	/usr/local/home/jlnance/y.c: In function `void badfun(char**)':
	/usr/local/home/jlnance/y.c:9: `struct utsname' has no member named 
	   `__domainname'

	I looked in the header files and it looks like this could be
	caused by __USE_GNU getting defined somehow for gcc but not for g++:

	    struct utsname
	      {

	      [snip]

	    #if _UTSNAME_DOMAIN_LENGTH - 0
		/* Name of the domain of this node on the network.  */
	    # ifdef __USE_GNU
		char domainname[_UTSNAME_DOMAIN_LENGTH];
	    # else
		char __domainname[_UTSNAME_DOMAIN_LENGTH];
	    # endif
	    #endif
	      };

>How-To-Repeat:

cat >y.c <<EOF
#include <sys/utsname.h>

void badfun(char * *aDomain)
{
    struct utsname buf;
    char *domainname = 0;

    /*domainname = buf.domainname;*/ /* Works with g++ */
    domainname = buf.__domainname;   /* Works with gcc */
}
EOF
gcc -o /dev/null -c y.c
g++ -o /dev/null -c y.c

>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
>From djk@super.org Sun Apr 01 00:00:00 2001
From: dan kopetzky <djk@super.org>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org
Subject: Re: c/1910: incorrect long long return value with -O2 optimization
Date: Sun, 01 Apr 2001 00:00:00 -0000
Message-id: <20010209131601.7922.qmail@sourceware.cygnus.com>
X-SW-Source: 2001-q1/msg01103.html
Content-length: 680

The following reply was made to PR c/1910; it has been noted by GNATS.

From: dan kopetzky <djk@super.org>
To: Richard Henderson <rth@redhat.com>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c/1910: incorrect long long return value with -O2 optimization
Date: Fri, 09 Feb 2001 08:13:19 -0500

 Richard Henderson wrote:
 
 > On Thu, Feb 08, 2001 at 01:14:45PM -0000, djk@super.org wrote:
 > >         struct cl val;
 > >         val.one = a;
 > >         val.two = 0;
 > >         return *(long long *)&val;
 >
 > This code is incorrect.  You are running afoul of ISO C
 > type aliasing rules.
 >
 > r~
 
 Thanks for your prompt reply. I'll convert the offending code to use
 unions.
 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-03-31 10:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-31  2:27 other/1865: struct utsname members are different for g++ and gcc rth
  -- strict thread matches above, loose matches on Subject: below --
2001-04-01  0:00 jnance

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).