public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/25801] New: bad diagnostic for increment/decrement of pointer to incomplete array
@ 2006-01-16 0:28 jsm28 at gcc dot gnu dot org
2006-01-16 1:25 ` [Bug c/25801] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 5+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2006-01-16 0:28 UTC (permalink / raw)
To: gcc-bugs
extern int (*a)[];
void g(void) { a++; }
yields the diagnostics
t2.c: In function 'g':
t2.c:2: error: increment of pointer to unknown structure
t2.c:2: error: arithmetic on pointer to an incomplete type
This isn't a pointer to a structure, it's one to an array; and after giving the
first diagnostic, it's useless to go on and give the second as well.
--
Summary: bad diagnostic for increment/decrement of pointer to
incomplete array
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jsm28 at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25801
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/25801] bad diagnostic for increment/decrement of pointer to incomplete array
2006-01-16 0:28 [Bug c/25801] New: bad diagnostic for increment/decrement of pointer to incomplete array jsm28 at gcc dot gnu dot org
@ 2006-01-16 1:25 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-16 1:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-01-16 01:25 -------
The problem with the first error message is obvious where it goes wrong (in
c-typeck.c):
if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (result_type)))
{
if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
error ("increment of pointer to unknown structure");
else
error ("decrement of pointer to unknown structure");
The second one comes from calling c_size_in_bytes. It seems like we can remove
the error call from c_size_in_bytes as the other place were we call it, we
check for a imcomplete type right before calling it.
Oh and the second error message also happens with the struct case too.
Both are these problems are not a regression as far as I can tell as both wrong
error messages are in 2.95.3.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |minor
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |diagnostic
Known to fail| |2.95.3 3.3.1 3.0.4 3.4.0
| |4.0.0 4.1.0 4.2.0
Last reconfirmed|0000-00-00 00:00:00 |2006-01-16 01:25:15
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25801
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/25801] bad diagnostic for increment/decrement of pointer to incomplete array
[not found] <bug-25801-4@http.gcc.gnu.org/bugzilla/>
2014-04-18 17:04 ` mpolacek at gcc dot gnu.org
2014-05-02 18:14 ` mpolacek at gcc dot gnu.org
@ 2014-05-02 18:15 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-05-02 18:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25801
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/25801] bad diagnostic for increment/decrement of pointer to incomplete array
[not found] <bug-25801-4@http.gcc.gnu.org/bugzilla/>
2014-04-18 17:04 ` mpolacek at gcc dot gnu.org
@ 2014-05-02 18:14 ` mpolacek at gcc dot gnu.org
2014-05-02 18:15 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-05-02 18:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25801
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Fri May 2 18:13:43 2014
New Revision: 210013
URL: http://gcc.gnu.org/viewcvs?rev=210013&root=gcc&view=rev
Log:
PR c/25801
* c-typeck.c (c_size_in_bytes): Update comment. Don't call error.
Return size_one_node when the type is not complete.
(pointer_diff): Remove comment.
(build_unary_op): Improve error messages.
* gcc.dg/pr25801.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/pr25801.c
Modified:
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-typeck.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/25801] bad diagnostic for increment/decrement of pointer to incomplete array
[not found] <bug-25801-4@http.gcc.gnu.org/bugzilla/>
@ 2014-04-18 17:04 ` mpolacek at gcc dot gnu.org
2014-05-02 18:14 ` mpolacek at gcc dot gnu.org
2014-05-02 18:15 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-04-18 17:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25801
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC| |mpolacek at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I'm testing a patch.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-05-02 18:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-16 0:28 [Bug c/25801] New: bad diagnostic for increment/decrement of pointer to incomplete array jsm28 at gcc dot gnu dot org
2006-01-16 1:25 ` [Bug c/25801] " pinskia at gcc dot gnu dot org
[not found] <bug-25801-4@http.gcc.gnu.org/bugzilla/>
2014-04-18 17:04 ` mpolacek at gcc dot gnu.org
2014-05-02 18:14 ` mpolacek at gcc dot gnu.org
2014-05-02 18:15 ` mpolacek at gcc dot gnu.org
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).