public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/9762: Address of 'char' is incorrect.
@ 2003-02-20 20:33 neil
0 siblings, 0 replies; 7+ messages in thread
From: neil @ 2003-02-20 20:33 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, stephen.kennedy
Synopsis: Address of 'char' is incorrect.
State-Changed-From-To: feedback->closed
State-Changed-By: neil
State-Changed-When: Thu Feb 20 20:33:30 2003
State-Changed-Why:
Not a bug, just not what user expected.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9762
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: c/9762: Address of 'char' is incorrect.
@ 2003-02-20 19:06 Daniel Jacobowitz
0 siblings, 0 replies; 7+ messages in thread
From: Daniel Jacobowitz @ 2003-02-20 19:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c/9762; it has been noted by GNATS.
From: Daniel Jacobowitz <dan@debian.org>
To: Stephen Kennedy <Stephen.Kennedy@havok.com>
Cc: 'Neil Booth' <neil@daikokuya.co.uk>, gcc-gnats@gcc.gnu.org,
debian-gcc@lists.debian.org
Subject: Re: c/9762: Address of 'char' is incorrect.
Date: Thu, 20 Feb 2003 14:03:30 -0500
On Thu, Feb 20, 2003 at 06:32:19PM -0000, Stephen Kennedy wrote:
>
> OK, the C standard does not say that this should work, so you
> can consider this bug closed.
>
> However, given knowledge of the calling convention of a
> particular machine, you can do neat things such as dynamic
> function binding. See www.drizzle.com/~scottb/gdc/fubi-paper.htm
> for instance.
>
> I've since changed to using assembly, but why does gcc
> return the address of a temp when 'a' is a char and not
> when 'a' is an int?
Because it's passed as an int; you have to convert it to a char on
arrival in the function.
>
> Surprised, not unhappy,
> Stephen.
>
> ---
> Stephen Kennedy <Stephen.Kennedy@havok.com>
> t: +353 1 6693679 f: +353 1 6767094
> Game Developer Frontline Award Winner
> http://www.havok.com/news/release.html
>
> > > In the example below, '&a' is the address of a local
> > copy of 'a' not of 'a'.
> > > if the type of 'a' is changed to int, it works as expected.
> >
> > Works as who expected? Where is the bug? Please quote which part of
> > the C standard is violated. You got an address, why are you unhappy?
> >
> > Neil.
> >
> > > #define TA char
> > > #define TB int
> > > #define TC int
> > >
> > > void foobar(TA a, TB b, TC c);
> > >
> > > int main()
> > > {
> > > foobar(1,2,3);
> > > return 0;
> > > }
> > >
> > > void foobar(TA a, TB b, TC c)
> > > {
> > > printf("a == %i claims %x\n", a, &a);
> > > printf("a == %i really %x\n", (&b)[-1], (&b)-1);
> > > printf("b == %i %x\n", b, &b);
> > > printf("c == %i %x\n", c, &c);
> > > }
> >
>
>
> --
> To UNSUBSCRIBE, email to debian-gcc-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
>
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: c/9762: Address of 'char' is incorrect.
@ 2003-02-20 18:36 Stephen Kennedy
0 siblings, 0 replies; 7+ messages in thread
From: Stephen Kennedy @ 2003-02-20 18:36 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c/9762; it has been noted by GNATS.
From: "Stephen Kennedy" <Stephen.Kennedy@havok.com>
To: "'Neil Booth'" <neil@daikokuya.co.uk>
Cc: <gcc-gnats@gcc.gnu.org>,
<debian-gcc@lists.debian.org>
Subject: RE: c/9762: Address of 'char' is incorrect.
Date: Thu, 20 Feb 2003 18:32:19 -0000
OK, the C standard does not say that this should work, so you
can consider this bug closed.
However, given knowledge of the calling convention of a
particular machine, you can do neat things such as dynamic
function binding. See www.drizzle.com/~scottb/gdc/fubi-paper.htm
for instance.
I've since changed to using assembly, but why does gcc
return the address of a temp when 'a' is a char and not
when 'a' is an int?
Surprised, not unhappy,
Stephen.
---
Stephen Kennedy <Stephen.Kennedy@havok.com>
t: +353 1 6693679 f: +353 1 6767094
Game Developer Frontline Award Winner
http://www.havok.com/news/release.html
> > In the example below, '&a' is the address of a local
> copy of 'a' not of 'a'.
> > if the type of 'a' is changed to int, it works as expected.
>
> Works as who expected? Where is the bug? Please quote which part of
> the C standard is violated. You got an address, why are you unhappy?
>
> Neil.
>
> > #define TA char
> > #define TB int
> > #define TC int
> >
> > void foobar(TA a, TB b, TC c);
> >
> > int main()
> > {
> > foobar(1,2,3);
> > return 0;
> > }
> >
> > void foobar(TA a, TB b, TC c)
> > {
> > printf("a == %i claims %x\n", a, &a);
> > printf("a == %i really %x\n", (&b)[-1], (&b)-1);
> > printf("b == %i %x\n", b, &b);
> > printf("c == %i %x\n", c, &c);
> > }
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: c/9762: Address of 'char' is incorrect.
@ 2003-02-20 14:36 Andreas Schwab
0 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2003-02-20 14:36 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1038 bytes --]
The following reply was made to PR c/9762; it has been noted by GNATS.
From: Andreas Schwab <schwab@suse.de>
To: stephen.kennedy@havok.com
Cc: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org
Subject: Re: c/9762: Address of 'char' is incorrect.
Date: Thu, 20 Feb 2003 15:26:33 +0100
stephen.kennedy@havok.com writes:
|> #define TA char
|> #define TB int
|> #define TC int
|>
|> void foobar(TA a, TB b, TC c);
|>
|> int main()
|> {
|> foobar(1,2,3);
|> return 0;
|> }
|>
|> void foobar(TA a, TB b, TC c)
|> {
|> printf("a == %i claims %x\n", a, &a);
|> printf("a == %i really %x\n", (&b)[-1], (&b)-1);
There is nothing in the C standard that requires that (char*)(&b-1) == &a.
They are distinct objects, thus not comparable, and &b-1 by itself is
already invalid.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: c/9762: Address of 'char' is incorrect.
@ 2003-02-20 8:06 ebotcazou
0 siblings, 0 replies; 7+ messages in thread
From: ebotcazou @ 2003-02-20 8:06 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, stephen.kennedy
Synopsis: Address of 'char' is incorrect.
State-Changed-From-To: open->feedback
State-Changed-By: ebotcazou
State-Changed-When: Thu Feb 20 08:06:46 2003
State-Changed-Why:
Neil's question.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9762
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: c/9762: Address of 'char' is incorrect.
@ 2003-02-19 21:26 Neil Booth
0 siblings, 0 replies; 7+ messages in thread
From: Neil Booth @ 2003-02-19 21:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c/9762; it has been noted by GNATS.
From: Neil Booth <neil@daikokuya.co.uk>
To: stephen.kennedy@havok.com
Cc: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org
Subject: Re: c/9762: Address of 'char' is incorrect.
Date: Wed, 19 Feb 2003 21:23:55 +0000
stephen.kennedy@havok.com wrote:-
> In the example below, '&a' is the address of a local copy of 'a' not of 'a'.
> if the type of 'a' is changed to int, it works as expected.
Works as who expected? Where is the bug? Please quote which part of
the C standard is violated. You got an address, why are you unhappy?
Neil.
> #define TA char
> #define TB int
> #define TC int
>
> void foobar(TA a, TB b, TC c);
>
> int main()
> {
> foobar(1,2,3);
> return 0;
> }
>
> void foobar(TA a, TB b, TC c)
> {
> printf("a == %i claims %x\n", a, &a);
> printf("a == %i really %x\n", (&b)[-1], (&b)-1);
> printf("b == %i %x\n", b, &b);
> printf("c == %i %x\n", c, &c);
> }
^ permalink raw reply [flat|nested] 7+ messages in thread
* c/9762: Address of 'char' is incorrect.
@ 2003-02-19 19:56 stephen.kennedy
0 siblings, 0 replies; 7+ messages in thread
From: stephen.kennedy @ 2003-02-19 19:56 UTC (permalink / raw)
To: gcc-gnats, debian-gcc
>Number: 9762
>Category: c
>Synopsis: Address of 'char' is incorrect.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Wed Feb 19 19:56:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Stephen Kennedy
>Release: 3.2.3 20030210 (Debian prerelease) (Debian testing/unstable)
>Organization:
Telekinesys Research
>Environment:
System: Linux stag 2.4.19-686 #1 Thu Aug 8 21:30:09 EST 2002 i686 unknown
Architecture: i686
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,pascal,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux
>Description:
In the example below, '&a' is the address of a local copy of 'a' not of 'a'.
if the type of 'a' is changed to int, it works as expected.
>How-To-Repeat:
#define TA char
#define TB int
#define TC int
void foobar(TA a, TB b, TC c);
int main()
{
foobar(1,2,3);
return 0;
}
void foobar(TA a, TB b, TC c)
{
printf("a == %i claims %x\n", a, &a);
printf("a == %i really %x\n", (&b)[-1], (&b)-1);
printf("b == %i %x\n", b, &b);
printf("c == %i %x\n", c, &c);
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-02-20 20:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-20 20:33 c/9762: Address of 'char' is incorrect neil
-- strict thread matches above, loose matches on Subject: below --
2003-02-20 19:06 Daniel Jacobowitz
2003-02-20 18:36 Stephen Kennedy
2003-02-20 14:36 Andreas Schwab
2003-02-20 8:06 ebotcazou
2003-02-19 21:26 Neil Booth
2003-02-19 19:56 stephen.kennedy
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).