public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/35616]  New: Incorrect code while O2 compling
@ 2008-03-17 16:24 J dot Gorka at osmosys dot tv
  2008-03-17 16:41 ` [Bug middle-end/35616] " pinskia at gcc dot gnu dot org
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: J dot Gorka at osmosys dot tv @ 2008-03-17 16:24 UTC (permalink / raw)
  To: gcc-bugs

While compling program below (3 files) with O2 or O3 option, code is generated
not properly (SF).


/******************************************************************************/

file 1:
gcc_bug.c

#include <stdio.h>
#include "function.h"

static void my_listener(
        int a,
        int b,
        int c)
{
  printf("It works!!!\n");
}

static struct data_t data;

int main()
{
  data.listener = my_listener;

  data.a = 11;
  data.b = 22;
  data.c = 33; /* with O2 compiling, function_calling_listener try call
function with address 33,
                  not my_listener address */
  data.d = 44;

  function_calling_listener(data);

  return 0;
}

/******************************************************************************/

file 2:
function.h

typedef void (*listener_fun)(
        int a,
        int b,
        int c);

struct data_t
{
  int a;

  listener_fun listener;

  int b;
  int c;
  int d;
};

void function_calling_listener (struct data_t data);

/******************************************************************************/

file 3:
function.c

#include "function.h"

void function_calling_listener (struct data_t data)
{
  data.listener(data.a, data.c, data.d);
}

/******************************************************************************/

GCC VERSION:
gcc --version
gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-13)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


-- 
           Summary: Incorrect code while O2 compling
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: J dot Gorka at osmosys dot tv


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


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

end of thread, other threads:[~2009-03-31 15:26 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-17 16:24 [Bug c/35616] New: Incorrect code while O2 compling J dot Gorka at osmosys dot tv
2008-03-17 16:41 ` [Bug middle-end/35616] " pinskia at gcc dot gnu dot org
2008-03-17 17:13 ` J dot Gorka at osmosys dot tv
2008-03-18  7:58 ` J dot Gorka at osmosys dot tv
2008-03-18  8:02 ` pinskia at gcc dot gnu dot org
2008-03-18  8:18 ` J dot Gorka at osmosys dot tv
2008-03-18 10:52 ` [Bug target/35616] [4.1/4.2/4.3/4.4 Regression] " rguenth at gcc dot gnu dot org
2008-03-18 14:34 ` ubizjak at gmail dot com
2008-03-18 14:45 ` ubizjak at gmail dot com
2008-03-18 14:54 ` rguenth at gcc dot gnu dot org
2008-03-18 14:56 ` matz at gcc dot gnu dot org
2008-03-18 15:02 ` ubizjak at gmail dot com
2008-03-18 15:04 ` matz at gcc dot gnu dot org
2008-03-18 15:26 ` rguenth at gcc dot gnu dot org
2008-03-18 15:30 ` ubizjak at gmail dot com
2008-03-18 15:38 ` matz at gcc dot gnu dot org
2008-03-18 16:01 ` [Bug middle-end/35616] " matz at gcc dot gnu dot org
2008-03-18 17:27 ` rguenth at gcc dot gnu dot org
2008-03-19 19:16 ` matz at gcc dot gnu dot org
2008-03-19 19:39 ` matz at gcc dot gnu dot org
2008-03-19 19:41 ` [Bug middle-end/35616] [4.1/4.2 " matz at gcc dot gnu dot org
2008-07-04 22:40 ` [Bug middle-end/35616] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-31 15:26 ` 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).