public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/35235] New: struct/union rvalue qualifiers must not propagate to members
@ 2008-02-17 17:15 truedfx at gentoo dot org
2008-02-17 23:15 ` [Bug c/35235] " jsm28 at gcc dot gnu dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: truedfx at gentoo dot org @ 2008-02-17 17:15 UTC (permalink / raw)
To: gcc-bugs
Hi,
This turns out to be a strictly conforming C99 program:
#include <stdlib.h>
int main(void) {
const struct {
int array[1];
} s;
// int *from_lvalue = s.array; // #1
int *from_rvalue = (rand() ? s : s).array; // #2
}
#1, if uncommented, should be rejected with -std=c99 -pedantic-errors, and
quite rightly is. However, in #2, the result of the conditional expression is
not an lvalue. C99 6.7.3p3 states that type qualifiers are not meaningful for
non-lvalues. Because of that, the type of (rand() ? s : s).array is int[1], not
const int[1], and it converts to int*, not const int*. This means the
initialization should be allowed, even though there is nothing you are allowed
to do with from_rvalue afterwards. It is certainly true that this code is
complete rubbish, and this handling by gcc should not cause any problems in any
real-world code, but technically, it's a bug, so I'm reporting it here.
The code is rejected in gcc 4.1 (4.1.2), 4.2 (4.2.2) and 4.3 (4.3-20080208). It
used to be accepted in older versions (3.3.6, 3.4.6, 4.0.4), but in those older
versions, no warning was given even for #1. Because of that, I'm not sure if
this qualifies as a regression.
--
Summary: struct/union rvalue qualifiers must not propagate to
members
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: truedfx at gentoo dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35235
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/35235] struct/union rvalue qualifiers must not propagate to members
2008-02-17 17:15 [Bug c/35235] New: struct/union rvalue qualifiers must not propagate to members truedfx at gentoo dot org
@ 2008-02-17 23:15 ` jsm28 at gcc dot gnu dot org
2008-07-04 19:31 ` [Bug c/35235] [4.2/4.3/4.4 Regression] " jsm28 at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-02-17 23:15 UTC (permalink / raw)
To: gcc-bugs
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO| |16989
nThis| |
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Priority|P3 |P4
Last reconfirmed|0000-00-00 00:00:00 |2008-02-17 23:14:23
date| |
Target Milestone|--- |4.1.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35235
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/35235] [4.2/4.3/4.4 Regression] struct/union rvalue qualifiers must not propagate to members
2008-02-17 17:15 [Bug c/35235] New: struct/union rvalue qualifiers must not propagate to members truedfx at gentoo dot org
2008-02-17 23:15 ` [Bug c/35235] " jsm28 at gcc dot gnu dot org
@ 2008-07-04 19:31 ` jsm28 at gcc dot gnu dot org
2009-02-04 17:15 ` jsm28 at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 19:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jsm28 at gcc dot gnu dot org 2008-07-04 19:30 -------
Closing 4.1 branch.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|struct/union rvalue |[4.2/4.3/4.4 Regression]
|qualifiers must not |struct/union rvalue
|propagate to members |qualifiers must not
| |propagate to members
Target Milestone|4.1.3 |4.2.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35235
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/35235] [4.2/4.3/4.4 Regression] struct/union rvalue qualifiers must not propagate to members
2008-02-17 17:15 [Bug c/35235] New: struct/union rvalue qualifiers must not propagate to members truedfx at gentoo dot org
2008-02-17 23:15 ` [Bug c/35235] " jsm28 at gcc dot gnu dot org
2008-07-04 19:31 ` [Bug c/35235] [4.2/4.3/4.4 Regression] " jsm28 at gcc dot gnu dot org
@ 2009-02-04 17:15 ` jsm28 at gcc dot gnu dot org
2009-02-04 21:03 ` jsm28 at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-02-04 17:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jsm28 at gcc dot gnu dot org 2009-02-04 17:14 -------
Working on a patch.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jsm28 at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2008-12-29 07:07:08 |2009-02-04 17:14:54
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35235
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/35235] [4.2/4.3/4.4 Regression] struct/union rvalue qualifiers must not propagate to members
2008-02-17 17:15 [Bug c/35235] New: struct/union rvalue qualifiers must not propagate to members truedfx at gentoo dot org
` (2 preceding siblings ...)
2009-02-04 17:15 ` jsm28 at gcc dot gnu dot org
@ 2009-02-04 21:03 ` jsm28 at gcc dot gnu dot org
2009-03-30 1:26 ` [Bug c/35235] [4.2/4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
2009-03-30 1:29 ` jsm28 at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-02-04 21:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jsm28 at gcc dot gnu dot org 2009-02-04 21:02 -------
Subject: Bug 35235
Author: jsm28
Date: Wed Feb 4 21:02:42 2009
New Revision: 143940
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143940
Log:
PR c/35235
* c-typeck.c (build_component_ref): Do not copy qualifiers from
non-lvalue to component.
testsuite:
* gcc.dg/c99-array-lval-8.c: New test.
Added:
branches/c-4_5-branch/gcc/testsuite/gcc.dg/c99-array-lval-8.c
Modified:
branches/c-4_5-branch/gcc/ChangeLog.c45
branches/c-4_5-branch/gcc/c-typeck.c
branches/c-4_5-branch/gcc/testsuite/ChangeLog.c45
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35235
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/35235] [4.2/4.3/4.4/4.5 Regression] struct/union rvalue qualifiers must not propagate to members
2008-02-17 17:15 [Bug c/35235] New: struct/union rvalue qualifiers must not propagate to members truedfx at gentoo dot org
` (3 preceding siblings ...)
2009-02-04 21:03 ` jsm28 at gcc dot gnu dot org
@ 2009-03-30 1:26 ` jsm28 at gcc dot gnu dot org
2009-03-30 1:29 ` jsm28 at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-30 1:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jsm28 at gcc dot gnu dot org 2009-03-30 01:25 -------
Subject: Bug 35235
Author: jsm28
Date: Mon Mar 30 01:25:37 2009
New Revision: 145271
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145271
Log:
PR c/35235
* c-typeck.c (build_component_ref): Do not copy qualifiers from
non-lvalue to component.
testsuite:
* gcc.dg/c99-array-lval-8.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/c99-array-lval-8.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-typeck.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35235
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/35235] [4.2/4.3/4.4/4.5 Regression] struct/union rvalue qualifiers must not propagate to members
2008-02-17 17:15 [Bug c/35235] New: struct/union rvalue qualifiers must not propagate to members truedfx at gentoo dot org
` (4 preceding siblings ...)
2009-03-30 1:26 ` [Bug c/35235] [4.2/4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
@ 2009-03-30 1:29 ` jsm28 at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-30 1:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jsm28 at gcc dot gnu dot org 2009-03-30 01:29 -------
Fixed for 4.5. Fix depends on changes not suitable for backporting.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Known to work|4.0.1 3.3.3 |4.0.1 3.3.3 4.5.0
Resolution| |FIXED
Target Milestone|4.2.5 |4.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35235
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-03-30 1:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-17 17:15 [Bug c/35235] New: struct/union rvalue qualifiers must not propagate to members truedfx at gentoo dot org
2008-02-17 23:15 ` [Bug c/35235] " jsm28 at gcc dot gnu dot org
2008-07-04 19:31 ` [Bug c/35235] [4.2/4.3/4.4 Regression] " jsm28 at gcc dot gnu dot org
2009-02-04 17:15 ` jsm28 at gcc dot gnu dot org
2009-02-04 21:03 ` jsm28 at gcc dot gnu dot org
2009-03-30 1:26 ` [Bug c/35235] [4.2/4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
2009-03-30 1:29 ` jsm28 at gcc dot gnu dot 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).