public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/41921]  New: Cross language don't work with unnamed structs
@ 2009-11-03  6:29 pinskia at gcc dot gnu dot org
  2009-11-03  6:31 ` [Bug lto/41921] Cross language don't work with typedef " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-11-03  6:29 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1313 bytes --]

With a C++ file as:
extern "C" {
  typedef struct {} CvImage;
     extern CvImage* Cv_ImageNew(void);
     }
 extern void _Raytrace(CvImage* LImage);
       int main(int LArgC, char** LArgV) 
{
  CvImage* LImage = Cv_ImageNew();
  _Raytrace(LImage);
 }
--- CUT --
And a C file as:

  typedef struct {} CvImage;
 CvImage* Cv_ImageNew(void) { }

--- CUT ---
We get an ICE when doing:
 gcc -O3 -flto -r -nostdlib t0.cc t1.c
In file included from :0:0:
t0.cc: In function ‘main’:
t0.cc:6:12: error: non-trivial conversion at assignment
struct CvImage *
struct 
{
} *
LImage_1 = D.1869_4(D);

t0.cc:6:12: internal compiler error: verify_stmts failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: /home/apinski/change-gcc/bin/gcc returned 1 exit status
collect2: lto-wrapper returned 1 exit status


-- 
           Summary: Cross language don't work with unnamed structs
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: lto
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41921


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/41921] Cross language don't work with typedef unnamed structs
  2009-11-03  6:29 [Bug lto/41921] New: Cross language don't work with unnamed structs pinskia at gcc dot gnu dot org
  2009-11-03  6:31 ` [Bug lto/41921] Cross language don't work with typedef " pinskia at gcc dot gnu dot org
@ 2009-11-03  6:31 ` pinskia at gcc dot gnu dot org
  2009-11-03  6:35 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-11-03  6:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2009-11-03 06:31 -------
This works if the struct is named too.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41921


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/41921] Cross language don't work with typedef unnamed structs
  2009-11-03  6:29 [Bug lto/41921] New: Cross language don't work with unnamed structs pinskia at gcc dot gnu dot org
@ 2009-11-03  6:31 ` pinskia at gcc dot gnu dot org
  2009-11-03  6:31 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-11-03  6:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-11-03 06:30 -------
This works if both are compiled with the C++ front-end (and an extern "C" is
added to the definition of Cv_ImageNew).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41921


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/41921] Cross language don't work with typedef unnamed structs
  2009-11-03  6:29 [Bug lto/41921] New: Cross language don't work with unnamed structs pinskia at gcc dot gnu dot org
  2009-11-03  6:31 ` [Bug lto/41921] Cross language don't work with typedef " pinskia at gcc dot gnu dot org
  2009-11-03  6:31 ` pinskia at gcc dot gnu dot org
@ 2009-11-03  6:35 ` pinskia at gcc dot gnu dot org
  2009-11-03 10:11 ` rguenth at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-11-03  6:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2009-11-03 06:35 -------
It also works if I "convert" the C++ source into a C (removing the extern "C"
stuff).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41921


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/41921] Cross language don't work with typedef unnamed structs
  2009-11-03  6:29 [Bug lto/41921] New: Cross language don't work with unnamed structs pinskia at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2009-11-03  6:35 ` pinskia at gcc dot gnu dot org
@ 2009-11-03 10:11 ` rguenth at gcc dot gnu dot org
  2009-11-03 11:46 ` [Bug c++/41921] " rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-11-03 10:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2009-11-03 10:11 -------
I will have a look.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-11-03 10:11:17
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41921


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/41921] Cross language don't work with typedef unnamed structs
  2009-11-03  6:29 [Bug lto/41921] New: Cross language don't work with unnamed structs pinskia at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2009-11-03 10:11 ` rguenth at gcc dot gnu dot org
@ 2009-11-03 11:46 ` rguenth at gcc dot gnu dot org
  2009-11-03 12:15 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-11-03 11:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2009-11-03 11:46 -------
The C++ FE for

extern "C" { typedef struct {} CvImage; }

creates

 <record_type 0x7ffff6f3f790 CvImage type_5 QI
    size <integer_cst 0x7ffff7ed5180 type <integer_type 0x7ffff7eea0b0
bit_size_type> constant 8>
    unit size <integer_cst 0x7ffff7ed51b0 type <integer_type 0x7ffff7eea000
long unsigned int> constant 1>
    align 8 symtab 0 alias set -1 canonical type 0x7ffff6f3f790
    fields <type_decl 0x7ffff6f3a6c0 ._0 type <record_type 0x7ffff6f3f790
CvImage>
        nonlocal decl_4 VOID file t1.C line 2 col 20
        align 1 context <record_type 0x7ffff6f3f790 CvImage>
       >
    full-name "struct CvImage"
    X() X(constX&) this=(X&) n_parents=0 use_template=0 interface-unknown
    chain <type_decl 0x7ffff6f3a600 ._0>>

thus, a named type.  The C frontend generates a named type with the
main-variant being an unnamed type.  The C++ frontend also assigns
different sizes to it.  C FE variant:

 <record_type 0x7ffff6eeabb0 CvImage type_0 BLK
    size <integer_cst 0x7ffff7ed5d80 type <integer_type 0x7ffff7ee70b0
bit_size_type> constant 0>
    unit size <integer_cst 0x7ffff7ed50f0 type <integer_type 0x7ffff7ee7000
long unsigned int> constant 0>
    align 8 symtab 0 alias set -1 canonical type 0x7ffff6eeab00
    chain <type_decl 0x7ffff6efb000 D.1607>>

and its main-variant (which is also its canonical type):

 <record_type 0x7ffff6eeab00 type_0 BLK
    size <integer_cst 0x7ffff7ed5d80 type <integer_type 0x7ffff7ee70b0
bit_size_type> constant 0>
    unit size <integer_cst 0x7ffff7ed50f0 type <integer_type 0x7ffff7ee7000
long unsigned int> constant 0>
    align 8 symtab 0 alias set -1 canonical type 0x7ffff6eeab00
    chain <type_decl 0x7ffff6efb000 D.1607>>


While we could try hard to workaround this in LTO I think this is a
C++ frontend bug.  extern "C" should cause it to behave like the C
frontend.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|rguenth at gcc dot gnu dot  |unassigned at gcc dot gnu
                   |org                         |dot org
             Status|ASSIGNED                    |NEW
          Component|lto                         |c++
           Keywords|                            |lto


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41921


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/41921] Cross language don't work with typedef unnamed structs
  2009-11-03  6:29 [Bug lto/41921] New: Cross language don't work with unnamed structs pinskia at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2009-11-03 11:46 ` [Bug c++/41921] " rguenth at gcc dot gnu dot org
@ 2009-11-03 12:15 ` rguenth at gcc dot gnu dot org
  2009-11-03 16:17 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-11-03 12:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2009-11-03 12:15 -------
This also likely means that the pure C++ testcase

t1.C
-----
struct {} a;

t2.C
-----
typedef struct {} T;
extern T a;
void foo(void)
{
  a = T();
}


breaks.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41921


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/41921] Cross language don't work with typedef unnamed structs
  2009-11-03  6:29 [Bug lto/41921] New: Cross language don't work with unnamed structs pinskia at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2009-11-03 12:15 ` rguenth at gcc dot gnu dot org
@ 2009-11-03 16:17 ` pinskia at gcc dot gnu dot org
  2009-11-13 23:12 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-11-03 16:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2009-11-03 16:16 -------
Note the original testcase did not have an empty struct (which is the cause of
the different sizes).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41921


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/41921] Cross language don't work with typedef unnamed structs
  2009-11-03  6:29 [Bug lto/41921] New: Cross language don't work with unnamed structs pinskia at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2009-11-03 16:17 ` pinskia at gcc dot gnu dot org
@ 2009-11-13 23:12 ` pinskia at gcc dot gnu dot org
  2010-06-03 15:03 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-11-13 23:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2009-11-13 23:12 -------
I think this is related to PR 7221.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |7221


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41921


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/41921] Cross language don't work with typedef unnamed structs
  2009-11-03  6:29 [Bug lto/41921] New: Cross language don't work with unnamed structs pinskia at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2009-11-13 23:12 ` pinskia at gcc dot gnu dot org
@ 2010-06-03 15:03 ` rguenth at gcc dot gnu dot org
  2010-06-03 16:08 ` rguenth at gcc dot gnu dot org
  2010-06-03 16:09 ` rguenth at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-03 15:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from rguenth at gcc dot gnu dot org  2010-06-03 15:03 -------
This is fixed.  I have a testcase + testsuite patch.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.6.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41921


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/41921] Cross language don't work with typedef unnamed structs
  2009-11-03  6:29 [Bug lto/41921] New: Cross language don't work with unnamed structs pinskia at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2010-06-03 15:03 ` rguenth at gcc dot gnu dot org
@ 2010-06-03 16:08 ` rguenth at gcc dot gnu dot org
  2010-06-03 16:09 ` rguenth at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-03 16:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from rguenth at gcc dot gnu dot org  2010-06-03 16:08 -------
Subject: Bug 41921

Author: rguenth
Date: Thu Jun  3 16:08:10 2010
New Revision: 160226

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160226
Log:
2010-06-03  Richard Guenther  <rguenther@suse.de>

        PR lto/41921
        * lib/lto.exp: Always load gcc.exp.
        (lto-obj): For C source files invoke gcc_target_compile.
        * g++.dg/lto/20100603-1_0.C: New testcase.
        * g++.dg/lto/20100603-1_1.c: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/lto/20100603-1_0.C
    trunk/gcc/testsuite/g++.dg/lto/20100603-1_1.c
Modified:
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41921


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/41921] Cross language don't work with typedef unnamed structs
  2009-11-03  6:29 [Bug lto/41921] New: Cross language don't work with unnamed structs pinskia at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2010-06-03 16:08 ` rguenth at gcc dot gnu dot org
@ 2010-06-03 16:09 ` rguenth at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-03 16:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from rguenth at gcc dot gnu dot org  2010-06-03 16:09 -------
Subject: Bug 41921

Author: rguenth
Date: Thu Jun  3 16:08:49 2010
New Revision: 160227

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160227
Log:
2010-06-03  Richard Guenther  <rguenther@suse.de>

        PR lto/41921
        * lib/lto.exp: Always load gcc.exp.
        (lto-obj): For C source files invoke gcc_target_compile.
        * g++.dg/lto/20100603-1_0.C: New testcase.
        * g++.dg/lto/20100603-1_1.c: Likewise.

Modified:
    trunk/gcc/testsuite/lib/lto.exp


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41921


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-06-03 16:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-03  6:29 [Bug lto/41921] New: Cross language don't work with unnamed structs pinskia at gcc dot gnu dot org
2009-11-03  6:31 ` [Bug lto/41921] Cross language don't work with typedef " pinskia at gcc dot gnu dot org
2009-11-03  6:31 ` pinskia at gcc dot gnu dot org
2009-11-03  6:35 ` pinskia at gcc dot gnu dot org
2009-11-03 10:11 ` rguenth at gcc dot gnu dot org
2009-11-03 11:46 ` [Bug c++/41921] " rguenth at gcc dot gnu dot org
2009-11-03 12:15 ` rguenth at gcc dot gnu dot org
2009-11-03 16:17 ` pinskia at gcc dot gnu dot org
2009-11-13 23:12 ` pinskia at gcc dot gnu dot org
2010-06-03 15:03 ` rguenth at gcc dot gnu dot org
2010-06-03 16:08 ` rguenth at gcc dot gnu dot org
2010-06-03 16:09 ` rguenth 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).