public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bernd.edlinger at hotmail dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/56712] New: constuctor function is called twice
Date: Sun, 24 Mar 2013 15:55:00 -0000	[thread overview]
Message-ID: <bug-56712-4@http.gcc.gnu.org/bugzilla/> (raw)


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

             Bug #: 56712
           Summary: constuctor function is called twice
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: bernd.edlinger@hotmail.de


Created attachment 29713
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29713
cnt++ is accidentally called twice at -O2 or higher

The attached test program has a constructor function
with the __attribute__((constructor)) that is split
up into two parts construct.part.0 and construct
construct.part.0 is the part after "if (xx != 0) return;"

The problem is that both are put into the .ctors section
first the construct.part.0 and then construct.
Unfortunately the construct function is called before
construct.part.0 which has the check removed.

Therefore basically the constuctor is called twice:
cnt=2 at -O2 or -O3, but cnt=1 at -O1 or less.


             reply	other threads:[~2013-03-24 15:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-24 15:55 bernd.edlinger at hotmail dot de [this message]
2013-03-24 17:02 ` [Bug middle-end/56712] " pinskia at gcc dot gnu.org
2013-03-24 22:21 ` [Bug middle-end/56712] constructor " mikpe at it dot uu.se
2013-03-25 10:14 ` [Bug middle-end/56712] [4.6 Regression] " rguenth at gcc dot gnu.org
2013-03-26  6:14 ` bernd.edlinger at hotmail dot de
2013-03-26  6:16 ` bernd.edlinger at hotmail dot de
2013-03-26 10:24 ` mikpe at it dot uu.se
2013-03-26 19:19 ` bernd.edlinger at hotmail dot de
2013-04-12 16:17 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-56712-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).