public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/35708]  New: jump to label enters catch block
@ 2008-03-26 18:57 sds at gnu dot org
  2008-03-26 20:39 ` [Bug c++/35708] " rguenth at gcc dot gnu dot org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: sds at gnu dot org @ 2008-03-26 18:57 UTC (permalink / raw)
  To: gcc-bugs

uname -a
SunOS neron 5.9 Generic_112233-08 sun4u sparc SUNW,Sun-Fire-480R
g++ --version
g++ (GCC) 4.2.1

the following program fails with the error
======================================= zot.cc =================
int alloccount = 100;

struct object { int one_o; int allocstamp; };
    struct gcv_object_t {
      int one_o;
      /* Conversion to object. */
      operator object () const;
      /* Conversion from object. */
      gcv_object_t (object obj);
      /* Conversion from fake_gcv_object. */
      gcv_object_t (struct fake_gcv_object obj);
      /* Uninitialized object. */
      gcv_object_t ();
    };

  static inline int pgci_pointable (object obj) {
    return obj.one_o;
  }
  static inline int pgci_pointable (gcv_object_t obj) {
    return obj.one_o;
  }

gcv_object_t STACK[1];

int main (int argc, char *argv[]) {

  check_rehash_size: {
        if ((pgci_pointable(STACK[0]) ==
pgci_pointable((((object){one_o:(((int)(int)(((0 << 3) + 7UL)) << 0) +
((int)(int)(0) << 7)), allocstamp: alloccount}))))) {
         bad_rehash_size:
          goto check_rehash_size;
      }
       goto bad_rehash_size;
 }
}
======================================= zot.cc =================
$ g++ -c zot.cc
zot.cc: In function 'int main(int, char**)':
zot.cc:30: error: jump to label 'bad_rehash_size'
zot.cc:33: error:   from here
zot.cc:29: error:   enters catch block

I don't see any catch blocks here.
thanks.


-- 
           Summary: jump to label enters catch block
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sds at gnu dot org


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


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

* [Bug c++/35708] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
@ 2008-03-26 20:39 ` rguenth at gcc dot gnu dot org
  2008-03-26 20:44 ` sds at gnu dot org
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-03-26 20:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-03-26 20:39 -------
I think this is invalid, you are entering a scope that has objects constructed.


-- 


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


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

* [Bug c++/35708] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
  2008-03-26 20:39 ` [Bug c++/35708] " rguenth at gcc dot gnu dot org
@ 2008-03-26 20:44 ` sds at gnu dot org
  2008-03-28 22:47 ` bruno at clisp dot org
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: sds at gnu dot org @ 2008-03-26 20:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from sds at gnu dot org  2008-03-26 20:44 -------
so? the objects are created, used and discarded on the fly.


-- 


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


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

* [Bug c++/35708] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
  2008-03-26 20:39 ` [Bug c++/35708] " rguenth at gcc dot gnu dot org
  2008-03-26 20:44 ` sds at gnu dot org
@ 2008-03-28 22:47 ` bruno at clisp dot org
  2008-03-28 22:48 ` bruno at clisp dot org
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: bruno at clisp dot org @ 2008-03-28 22:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from bruno at clisp dot org  2008-03-28 22:46 -------
> you are entering a scope that has objects constructed.

Can you point out the sections in the ISO C++ standard that say that an 'if'
statement can create the scope for some objects?


-- 


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


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

* [Bug c++/35708] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
                   ` (2 preceding siblings ...)
  2008-03-28 22:47 ` bruno at clisp dot org
@ 2008-03-28 22:48 ` bruno at clisp dot org
  2008-03-29 10:53 ` rguenth at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: bruno at clisp dot org @ 2008-03-28 22:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from bruno at clisp dot org  2008-03-28 22:48 -------
The bug also occurs with g++ 4.3.0.


-- 


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


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

* [Bug c++/35708] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
                   ` (3 preceding siblings ...)
  2008-03-28 22:48 ` bruno at clisp dot org
@ 2008-03-29 10:53 ` rguenth at gcc dot gnu dot org
  2008-03-29 10:57 ` rguenth at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-03-29 10:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2008-03-29 10:52 -------
Here's a shorter testcase:

struct object { int one_o; int allocstamp; };
int pgci_pointable (object obj);
void foo(void);
int main (int argc, char *argv[])
{
  if (pgci_pointable((object){7,100}))
    {
      bad_rehash_size:
        foo();
    }
  goto bad_rehash_size;
}


If you look at the original IL as coming from the FE you see

  {
    <<cleanup_point     struct object D.1681 = {.one_o=7, .allocstamp=100};>>;
    <<< Unknown tree: if_stmt
       <<cleanup_point pgci_pointable (D.1681) != 0>>
       bad_rehash_size:;
         <<cleanup_point <<< Unknown tree: expr_stmt foo () >>> >>;
    >>> ;
  }
  goto bad_rehash_size;

which is gimplified to

  {
    {
      struct objectD.1670 D.1681;

      D.1681.one_oD.1672 = 7;
      D.1681.allocstampD.1673 = 100;
      D.1699 = pgci_pointable (D.1681);
      retval.0D.1698 = D.1699 != 0;
      if (retval.0D.1698)
        {
          bad_rehash_sizeD.1697:;
          foo ();
        }
      else
        {

        }
    }
    goto bad_rehash_sizeD.1697;
  }

at which point the goto enters a scope with local objects constructed
before the jump target.  Thus the FE generates a new scope around the
if statement where the temporary object is bound to and somehow this
is a of type sk_catch (that there is no checking whether something can
throw inside the block may be a problem).

With gcc 4.1 where the testcase is accepted we gimplify to

int main(int, char**) (argc, argv)
{
  boolD.1451 retval.0D.1759;
  struct objectD.1732 D.1760;
  intD.2 D.1761;
  intD.2 D.1762;

  D.1760.one_oD.1734 = 7;
  D.1760.allocstampD.1735 = 100;
  D.1761 = pgci_pointable (D.1760);
  retval.0D.1759 = D.1761 != 0;
  if (retval.0D.1759)
    {
      bad_rehash_sizeD.1758:;
      foo ();
    }
  else
    {

    }
  goto bad_rehash_sizeD.1758;

not creating this extra scope.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
      Known to fail|                            |4.2.3 4.3.0
      Known to work|                            |4.1.3


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


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

* [Bug c++/35708] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
                   ` (4 preceding siblings ...)
  2008-03-29 10:53 ` rguenth at gcc dot gnu dot org
@ 2008-03-29 10:57 ` rguenth at gcc dot gnu dot org
  2008-03-29 15:13 ` jason at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-03-29 10:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2008-03-29 10:56 -------
Jason, can you have a look here?


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot org


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


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

* [Bug c++/35708] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
                   ` (5 preceding siblings ...)
  2008-03-29 10:57 ` rguenth at gcc dot gnu dot org
@ 2008-03-29 15:13 ` jason at gcc dot gnu dot org
  2008-03-29 15:20 ` jason at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-03-29 15:13 UTC (permalink / raw)
  To: gcc-bugs



-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jason at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-03-29 15:13:00
               date|                            |


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


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

* [Bug c++/35708] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
                   ` (6 preceding siblings ...)
  2008-03-29 15:13 ` jason at gcc dot gnu dot org
@ 2008-03-29 15:20 ` jason at gcc dot gnu dot org
  2008-04-09 16:17 ` jason at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-03-29 15:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jason at gcc dot gnu dot org  2008-03-29 15:19 -------
The bug is that the temporary object created by the C99 compound literal syntax
doesn't have proper C++ temporary lifetime; the compiler treats it as living
until the end of the block, so the goto seems to be skipping its
initialization.  The compiler talks about a catch block because it assumes that
the only artificial decl a goto could jump into is the one for the catch
parameter.


-- 


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


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

* [Bug c++/35708] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
                   ` (7 preceding siblings ...)
  2008-03-29 15:20 ` jason at gcc dot gnu dot org
@ 2008-04-09 16:17 ` jason at gcc dot gnu dot org
  2008-04-09 19:58 ` jason at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-04-09 16:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jason at gcc dot gnu dot org  2008-04-09 16:16 -------
Subject: Bug 35708

Author: jason
Date: Wed Apr  9 16:15:53 2008
New Revision: 134146

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134146
Log:
        PR c++/35708
        * semantics.c (finish_compound_literal): Return a TARGET_EXPR,
        not a pushed variable.

Added:
    trunk/gcc/testsuite/g++.dg/ext/complit9.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/35708] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
                   ` (8 preceding siblings ...)
  2008-04-09 16:17 ` jason at gcc dot gnu dot org
@ 2008-04-09 19:58 ` jason at gcc dot gnu dot org
  2008-04-09 20:11 ` jason at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-04-09 19:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jason at gcc dot gnu dot org  2008-04-09 19:58 -------
Subject: Bug 35708

Author: jason
Date: Wed Apr  9 19:57:19 2008
New Revision: 134151

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134151
Log:
        PR c++/35708
        * semantics.c (finish_compound_literal): Return a TARGET_EXPR,
        not a pushed variable.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/g++.dg/ext/complit9.C
      - copied unchanged from r134146,
trunk/gcc/testsuite/g++.dg/ext/complit9.C
Modified:
    branches/gcc-4_3-branch/gcc/cp/ChangeLog
    branches/gcc-4_3-branch/gcc/cp/semantics.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/35708] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
                   ` (9 preceding siblings ...)
  2008-04-09 19:58 ` jason at gcc dot gnu dot org
@ 2008-04-09 20:11 ` jason at gcc dot gnu dot org
  2008-04-11 21:28 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-04-09 20:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from jason at gcc dot gnu dot org  2008-04-09 20:10 -------
Fixed for 4.3.1 and 4.4.0.  Patch seems risky for 4.2 at this point.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|4.1.3                       |4.1.3 4.3.1 4.4.0


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


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

* [Bug c++/35708] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
                   ` (10 preceding siblings ...)
  2008-04-09 20:11 ` jason at gcc dot gnu dot org
@ 2008-04-11 21:28 ` pinskia at gcc dot gnu dot org
  2008-04-11 21:29 ` [Bug c++/35708] [4.2 Regression] " pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-04-11 21:28 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.3.1


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


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

* [Bug c++/35708] [4.2 Regression] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
                   ` (11 preceding siblings ...)
  2008-04-11 21:28 ` pinskia at gcc dot gnu dot org
@ 2008-04-11 21:29 ` pinskia at gcc dot gnu dot org
  2008-05-19 20:35 ` jsm28 at gcc dot gnu dot org
  2008-12-02 17:24 ` jason at gcc dot gnu dot org
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-04-11 21:29 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|jump to label enters catch  |[4.2 Regression] jump to
                   |block                       |label enters catch block
   Target Milestone|4.3.1                       |4.2.4


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


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

* [Bug c++/35708] [4.2 Regression] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
                   ` (12 preceding siblings ...)
  2008-04-11 21:29 ` [Bug c++/35708] [4.2 Regression] " pinskia at gcc dot gnu dot org
@ 2008-05-19 20:35 ` jsm28 at gcc dot gnu dot org
  2008-12-02 17:24 ` jason at gcc dot gnu dot org
  14 siblings, 0 replies; 16+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-05-19 20:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from jsm28 at gcc dot gnu dot org  2008-05-19 20:25 -------
4.2.4 is being released, changing milestones to 4.2.5.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.2.4                       |4.2.5


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


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

* [Bug c++/35708] [4.2 Regression] jump to label enters catch block
  2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
                   ` (13 preceding siblings ...)
  2008-05-19 20:35 ` jsm28 at gcc dot gnu dot org
@ 2008-12-02 17:24 ` jason at gcc dot gnu dot org
  14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-12-02 17:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from jason at gcc dot gnu dot org  2008-12-02 17:12 -------
Fixed in 4.3.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2008-12-02 17:24 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-26 18:57 [Bug c++/35708] New: jump to label enters catch block sds at gnu dot org
2008-03-26 20:39 ` [Bug c++/35708] " rguenth at gcc dot gnu dot org
2008-03-26 20:44 ` sds at gnu dot org
2008-03-28 22:47 ` bruno at clisp dot org
2008-03-28 22:48 ` bruno at clisp dot org
2008-03-29 10:53 ` rguenth at gcc dot gnu dot org
2008-03-29 10:57 ` rguenth at gcc dot gnu dot org
2008-03-29 15:13 ` jason at gcc dot gnu dot org
2008-03-29 15:20 ` jason at gcc dot gnu dot org
2008-04-09 16:17 ` jason at gcc dot gnu dot org
2008-04-09 19:58 ` jason at gcc dot gnu dot org
2008-04-09 20:11 ` jason at gcc dot gnu dot org
2008-04-11 21:28 ` pinskia at gcc dot gnu dot org
2008-04-11 21:29 ` [Bug c++/35708] [4.2 Regression] " pinskia at gcc dot gnu dot org
2008-05-19 20:35 ` jsm28 at gcc dot gnu dot org
2008-12-02 17:24 ` jason 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).