public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/34326] New: pointer arithmetic on void pointers does not generate an error
@ 2007-12-03 16:00 jmparker at marvell dot com
2007-12-03 16:04 ` [Bug c/34326] " jmparker at marvell dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: jmparker at marvell dot com @ 2007-12-03 16:00 UTC (permalink / raw)
To: gcc-bugs
I was surprised that gcc did not find an error in the following example.
My understanding is that assignment to a void pointer is ok, but arithmetic
is _not_ ok. I have tried this code on my arm cross compiler gcc v. 4.1.1 and
my ubuntu system compiler 4.1.3. Gcc treats the void pointer type as char
gcc --version
gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
Example pointer arithmetic on a void pointer that should have caused an error
#include <stdlib.h>
int main (int argc, char **argv)
{
void *x;
x = malloc(1025 * sizeof(*x));
x++; // i expected an error on this line!
return 1;
}
--
Summary: pointer arithmetic on void pointers does not generate an
error
Product: gcc
Version: 4.1.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jmparker at marvell dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34326
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/34326] pointer arithmetic on void pointers does not generate an error
2007-12-03 16:00 [Bug c/34326] New: pointer arithmetic on void pointers does not generate an error jmparker at marvell dot com
@ 2007-12-03 16:04 ` jmparker at marvell dot com
2007-12-03 16:24 ` rguenth at gcc dot gnu dot org
2007-12-03 16:25 ` brian at dessent dot net
2 siblings, 0 replies; 4+ messages in thread
From: jmparker at marvell dot com @ 2007-12-03 16:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jmparker at marvell dot com 2007-12-03 16:03 -------
Created an attachment (id=14694)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14694&action=view)
simple .c example
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34326
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/34326] pointer arithmetic on void pointers does not generate an error
2007-12-03 16:00 [Bug c/34326] New: pointer arithmetic on void pointers does not generate an error jmparker at marvell dot com
2007-12-03 16:04 ` [Bug c/34326] " jmparker at marvell dot com
@ 2007-12-03 16:24 ` rguenth at gcc dot gnu dot org
2007-12-03 16:25 ` brian at dessent dot net
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-12-03 16:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2007-12-03 16:24 -------
This is a GCC extension. Use -pedantic to get a warning, -pedantic-errors to
get an error.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34326
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/34326] pointer arithmetic on void pointers does not generate an error
2007-12-03 16:00 [Bug c/34326] New: pointer arithmetic on void pointers does not generate an error jmparker at marvell dot com
2007-12-03 16:04 ` [Bug c/34326] " jmparker at marvell dot com
2007-12-03 16:24 ` rguenth at gcc dot gnu dot org
@ 2007-12-03 16:25 ` brian at dessent dot net
2 siblings, 0 replies; 4+ messages in thread
From: brian at dessent dot net @ 2007-12-03 16:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from brian at dessent dot net 2007-12-03 16:25 -------
Subject: Re: New: pointer arithmetic on void pointers does not
generate an error
This is a GNU C extension, see
<http://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html>. I think you can
disable it with -std=c89 or -std=c99.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34326
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-12-03 16:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-03 16:00 [Bug c/34326] New: pointer arithmetic on void pointers does not generate an error jmparker at marvell dot com
2007-12-03 16:04 ` [Bug c/34326] " jmparker at marvell dot com
2007-12-03 16:24 ` rguenth at gcc dot gnu dot org
2007-12-03 16:25 ` brian at dessent dot net
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).