public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/14661] New: ?: operator result structure's member array can't be assigned to pointer
@ 2004-03-20 1:19 dmj36 at email dot byu dot edu
2004-03-20 1:31 ` [Bug c/14661] [3.3? Regression] " pinskia at gcc dot gnu dot org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: dmj36 at email dot byu dot edu @ 2004-03-20 1:19 UTC (permalink / raw)
To: gcc-bugs
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs
Configured with: /netrel/src/gcc-3.3.1-2/configure --enable-
languages=c,c++,f77,java --enable-libgcj --enable-threads=posix --with-system-
zlib --enable-nls --without-included-gettext --enable-interpreter --enable-sjlj-
exceptions --disable-version-specific-runtime-libs --enable-shared --build=i686-
pc-linux --host=i686-pc-cygwin --target=i686-pc-cygwin --prefix=/usr --exec-
prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --
includedir=/nonexistent/include --libexecdir=/usr/sbin
Thread model: posix
gcc version 3.3.1 (cygming special)
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/cc1.exe -E -quiet -v -D__GNUC__=3 -
D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=1 -D__CYGWIN32__ -D__CYGWIN__ -Dunix -
D__unix__ -D__unix -idirafter /usr/lib/gcc-lib/i686-pc-
cygwin/3.3.1/../../../../include/w32api -idirafter /usr/lib/gcc-lib/i686-pc-
cygwin/3.3.1/../../../../i686-pc-cygwin/lib/../../include/w32api breaks-gcc.c
breaks-gcc.i
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/i686-pc-cygwin/include"
ignoring duplicate directory "/usr/i686-pc-cygwin/lib/../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include
/usr/include
/usr/include/w32api
End of search list.
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/cc1.exe -fpreprocessed breaks-gcc.i -
quiet -dumpbase breaks-gcc.c -auxbase breaks-gcc -version -o breaks-gcc.s
GNU C version 3.3.1 (cygming special) (i686-pc-cygwin)
compiled by GNU C version 3.3.1 (cygming special).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
breaks-gcc.c: In function `main':
breaks-gcc.c:23: internal compiler error: in emit_move_insn, at expr.c:3156
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Source file (breaks-gcc.i):
# 1 "breaks-gcc.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "breaks-gcc.c"
typedef unsigned short Uint16;
typedef struct Data_Struct {
Uint16 lever_arm[3];
} Data_Struct;
typedef enum Local_Foreign_Type {
LOCAL = 1,
FOREIGN = 2
} Local_Foreign_Type;
Data_Struct Local_Data = { { LOCAL, LOCAL, LOCAL } };
Data_Struct Foreign_Data = { { FOREIGN, FOREIGN, FOREIGN } };
int main(int argc, char *argv[]) {
Local_Foreign_Type source = LOCAL;
Uint16 *foo = (((((source) == FOREIGN) ? Foreign_Data :
Local_Data)).lever_arm);
# 43 "breaks-gcc.c"
return 0;
}
--
Summary: ?: operator result structure's member array can't be
assigned to pointer
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dmj36 at email dot byu dot edu
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14661
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/14661] [3.3? Regression] ?: operator result structure's member array can't be assigned to pointer
2004-03-20 1:19 [Bug c/14661] New: ?: operator result structure's member array can't be assigned to pointer dmj36 at email dot byu dot edu
@ 2004-03-20 1:31 ` pinskia at gcc dot gnu dot org
2004-03-20 2:54 ` reichelt at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-20 1:31 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-20 01:31 -------
I did not confirm this because I do not have a newer 3.3 gcc.
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-invalid-code
Known to fail| |3.3.1
Known to work| |3.4.0 3.5.0 3.0.4 3.2.3
Summary|?: operator result |[3.3? Regression] ?:
|structure's member array |operator result structure's
|can't be assigned to pointer|member array can't be
| |assigned to pointer
Target Milestone|--- |3.3.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14661
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/14661] [3.3? Regression] ?: operator result structure's member array can't be assigned to pointer
2004-03-20 1:19 [Bug c/14661] New: ?: operator result structure's member array can't be assigned to pointer dmj36 at email dot byu dot edu
2004-03-20 1:31 ` [Bug c/14661] [3.3? Regression] " pinskia at gcc dot gnu dot org
@ 2004-03-20 2:54 ` reichelt at gcc dot gnu dot org
2004-03-22 2:21 ` bangerth at dealii dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-03-20 2:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From reichelt at gcc dot gnu dot org 2004-03-20 02:54 -------
The code used to compile with gcc 2.95.x - 3.0.x, but ICEd with 3.1 - 3.3.1.
Since gcc 3.3.2 the ICE is gone - the code is rejected.
But is the code really invalid?
The code does compile as C++ source or with the option "-std=c99".
It also compiles, if I replace the condition (source == FOREIGN)
with a constant.
Here's a shorter example that demonstrates the problem:
======================================
struct A
{
char str[1];
};
struct A a = { "" };
struct A b = { "" };
void foo (int i)
{
char *p = ( i ? a : b ).str;
}
======================================
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |reichelt at gcc dot gnu dot
| |org
Known to fail|3.3.1 |3.1 3.1.1 3.1.2 3.2 3.2.1
| |3.2.2 3.2.3 3.3 3.3.1
Known to work|3.4.0 3.5.0 3.0.4 3.2.3 |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14661
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/14661] [3.3? Regression] ?: operator result structure's member array can't be assigned to pointer
2004-03-20 1:19 [Bug c/14661] New: ?: operator result structure's member array can't be assigned to pointer dmj36 at email dot byu dot edu
2004-03-20 1:31 ` [Bug c/14661] [3.3? Regression] " pinskia at gcc dot gnu dot org
2004-03-20 2:54 ` reichelt at gcc dot gnu dot org
@ 2004-03-22 2:21 ` bangerth at dealii dot org
2004-03-22 2:24 ` [Bug c/14661] [3.3?/3.4/3.5 " pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: bangerth at dealii dot org @ 2004-03-22 2:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-03-22 02:20 -------
In C, the result of the ?: operator is an rvalue, i.e.
( i ? a : b )
is a temporary of type A, and taking the address of its member
is assigning the address of a temporary to the result variable.
That should be legal, but should also yield undefined behavior.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14661
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/14661] [3.3?/3.4/3.5 Regression] ?: operator result structure's member array can't be assigned to pointer
2004-03-20 1:19 [Bug c/14661] New: ?: operator result structure's member array can't be assigned to pointer dmj36 at email dot byu dot edu
` (2 preceding siblings ...)
2004-03-22 2:21 ` bangerth at dealii dot org
@ 2004-03-22 2:24 ` pinskia at gcc dot gnu dot org
2004-03-22 9:52 ` jsm at polyomino dot org dot uk
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-22 2:24 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Summary|[3.3? Regression] ?: |[3.3?/3.4/3.5 Regression] ?:
|operator result structure's |operator result structure's
|member array can't be |member array can't be
|assigned to pointer |assigned to pointer
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14661
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/14661] [3.3?/3.4/3.5 Regression] ?: operator result structure's member array can't be assigned to pointer
2004-03-20 1:19 [Bug c/14661] New: ?: operator result structure's member array can't be assigned to pointer dmj36 at email dot byu dot edu
` (3 preceding siblings ...)
2004-03-22 2:24 ` [Bug c/14661] [3.3?/3.4/3.5 " pinskia at gcc dot gnu dot org
@ 2004-03-22 9:52 ` jsm at polyomino dot org dot uk
2004-03-22 14:40 ` [Bug c/14661] [3.3? " pinskia at gcc dot gnu dot org
2004-04-06 13:34 ` bangerth at dealii dot org
6 siblings, 0 replies; 8+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-03-22 9:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From jsm at polyomino dot org dot uk 2004-03-22 09:52 -------
Subject: Re: [3.3? Regression] ?: operator result structure's
member array can't be assigned to pointer
On Mon, 22 Mar 2004, bangerth at dealii dot org wrote:
> In C, the result of the ?: operator is an rvalue, i.e.
> ( i ? a : b )
> is a temporary of type A, and taking the address of its member
> is assigning the address of a temporary to the result variable.
> That should be legal, but should also yield undefined behavior.
But only C99 allows the non-lvalue array to convert to a pointer like
that.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14661
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/14661] [3.3? Regression] ?: operator result structure's member array can't be assigned to pointer
2004-03-20 1:19 [Bug c/14661] New: ?: operator result structure's member array can't be assigned to pointer dmj36 at email dot byu dot edu
` (4 preceding siblings ...)
2004-03-22 9:52 ` jsm at polyomino dot org dot uk
@ 2004-03-22 14:40 ` pinskia at gcc dot gnu dot org
2004-04-06 13:34 ` bangerth at dealii dot org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-22 14:40 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords|rejects-valid |
Summary|[3.3?/3.4/3.5 Regression] ?:|[3.3? Regression] ?:
|operator result structure's |operator result structure's
|member array can't be |member array can't be
|assigned to pointer |assigned to pointer
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14661
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/14661] [3.3? Regression] ?: operator result structure's member array can't be assigned to pointer
2004-03-20 1:19 [Bug c/14661] New: ?: operator result structure's member array can't be assigned to pointer dmj36 at email dot byu dot edu
` (5 preceding siblings ...)
2004-03-22 14:40 ` [Bug c/14661] [3.3? " pinskia at gcc dot gnu dot org
@ 2004-04-06 13:34 ` bangerth at dealii dot org
6 siblings, 0 replies; 8+ messages in thread
From: bangerth at dealii dot org @ 2004-04-06 13:34 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-04-06 13:33 -------
Given my and Joseph's comments, I understand that gcc's behavior is to
be expected.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Known to work| |3.3.2
Resolution| |INVALID
Target Milestone|3.3.4 |3.3.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14661
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-04-06 13:34 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-20 1:19 [Bug c/14661] New: ?: operator result structure's member array can't be assigned to pointer dmj36 at email dot byu dot edu
2004-03-20 1:31 ` [Bug c/14661] [3.3? Regression] " pinskia at gcc dot gnu dot org
2004-03-20 2:54 ` reichelt at gcc dot gnu dot org
2004-03-22 2:21 ` bangerth at dealii dot org
2004-03-22 2:24 ` [Bug c/14661] [3.3?/3.4/3.5 " pinskia at gcc dot gnu dot org
2004-03-22 9:52 ` jsm at polyomino dot org dot uk
2004-03-22 14:40 ` [Bug c/14661] [3.3? " pinskia at gcc dot gnu dot org
2004-04-06 13:34 ` bangerth at dealii 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).