public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37770]  New: static structures initialization, undefined reference to `_0'
@ 2008-10-08 10:33 amdmi3 at amdmi3 dot ru
  2008-10-08 12:41 ` [Bug c++/37770] " amdmi3 at amdmi3 dot ru
  2008-12-27  6:44 ` [Bug middle-end/37770] " pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: amdmi3 at amdmi3 dot ru @ 2008-10-08 10:33 UTC (permalink / raw)
  To: gcc-bugs

The bug is present with both system `gcc 4.2.1 20070719' and `gcc 4.2.5
20080702 (prerelease)' built from ports. Also present on both i386 and amd64,
althrough symptoms are different.

----- Code:
struct struct1 {
        int int1;
        int int2;
};

struct struct2 {
        struct2(const struct1 REF s) { S = s; }
        struct1 S;
};

static const struct2 arr[] = {
        struct2( (struct1){1,2} )
};

int main() {
        return arr[0].S.int1 + arr[0].S.int2;
}
-----

Symptoms:

$ g++ test.c -DREF=''
/var/tmp//ccad9L64.o(.text+0x40): In function
`__static_initialization_and_destruction_0(int, int)':
: undefined reference to `_0'
/var/tmp//ccad9L64.o(.text+0x45): In function
`__static_initialization_and_destruction_0(int, int)':
: undefined reference to `_0'
collect2: ld returned 1 exit status
$ g++ test.c -DREF='&'
$

-O2 reverses this behavior:

$ g++ -O2 test.c -DREF='&'
/var/tmp//ccPsUIZY.o(.text+0x31): In function
`__static_initialization_and_destruction_0(int, int)':
: undefined reference to `_0'
/var/tmp//ccPsUIZY.o(.text+0x3b): In function
`__static_initialization_and_destruction_0(int, int)':
: undefined reference to `_0'
collect2: ld returned 1 exit status
$ g++ -O2 test.c -DREF=''
$

On amd64 error messages are different:

$ g++ test.c -DREF=''
/var/tmp//cclgnYrV.s: Assembler messages:
/var/tmp//cclgnYrV.s:63: Error: junk `(%rip)' after expression
$ g++ test.c -DREF='&'
$ g++ -O2 test.c -DREF=''
$ g++ -O2 test.c -DREF='&'
/var/tmp//ccG5mp46.s: Assembler messages:
/var/tmp//ccG5mp46.s:31: Error: junk `(%rip)' after expression
/var/tmp//ccG5mp46.s:33: Error: junk `(%rip)' after expression
$


-- 
           Summary: static structures initialization, undefined reference to
                    `_0'
           Product: gcc
           Version: 4.2.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: amdmi3 at amdmi3 dot ru
 GCC build triplet: i386-portbld-freebsd7.0
  GCC host triplet: i386-portbld-freebsd7.0
GCC target triplet: i386-portbld-freebsd7.0


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


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

* [Bug c++/37770] static structures initialization, undefined reference to `_0'
  2008-10-08 10:33 [Bug c++/37770] New: static structures initialization, undefined reference to `_0' amdmi3 at amdmi3 dot ru
@ 2008-10-08 12:41 ` amdmi3 at amdmi3 dot ru
  2008-12-27  6:44 ` [Bug middle-end/37770] " pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: amdmi3 at amdmi3 dot ru @ 2008-10-08 12:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from amdmi3 at amdmi3 dot ru  2008-10-08 12:39 -------
Just tested gcc 4.3: this version doesn't seem to have this bug


-- 


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


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

* [Bug middle-end/37770] static structures initialization, undefined reference to `_0'
  2008-10-08 10:33 [Bug c++/37770] New: static structures initialization, undefined reference to `_0' amdmi3 at amdmi3 dot ru
  2008-10-08 12:41 ` [Bug c++/37770] " amdmi3 at amdmi3 dot ru
@ 2008-12-27  6:44 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-12-27  6:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-12-27 06:41 -------
THis works for me on different targets.

Can you try building GCC yourself without using the port system on freebsd?


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


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


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

end of thread, other threads:[~2008-12-27  6:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-08 10:33 [Bug c++/37770] New: static structures initialization, undefined reference to `_0' amdmi3 at amdmi3 dot ru
2008-10-08 12:41 ` [Bug c++/37770] " amdmi3 at amdmi3 dot ru
2008-12-27  6:44 ` [Bug middle-end/37770] " pinskia 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).