public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* warning not issued
@ 1998-10-21 13:42 Tudor Hulubei
  1998-10-21 22:10 ` Joe Buck
  1998-10-30  3:25 ` Alexandre Oliva
  0 siblings, 2 replies; 4+ messages in thread
From: Tudor Hulubei @ 1998-10-21 13:42 UTC (permalink / raw)
  To: egcs

Hi,

The following code does not warn you that the initialization of `t' is
skipped.  The result is a segfault when exiting main.  I'm using
egcs-1.1b on RedHat 5.1.

#include <vector>

int
main(int argc)
{
    goto done;
    vector<int> t;
  done:;
}

Regards,
Tudor

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

* Re: warning not issued
  1998-10-21 13:42 warning not issued Tudor Hulubei
@ 1998-10-21 22:10 ` Joe Buck
  1998-10-22 18:00   ` Martin von Loewis
  1998-10-30  3:25 ` Alexandre Oliva
  1 sibling, 1 reply; 4+ messages in thread
From: Joe Buck @ 1998-10-21 22:10 UTC (permalink / raw)
  To: tudor; +Cc: egcs

> The following code does not warn you that the initialization of `t' is
> skipped.  The result is a segfault when exiting main.

This is not legal C++; you can't jump around an initializer with a
goto or a switch unless the initializer is inside curly braces.
Just the same, the compiler should have caught it ... I'm sure this
was missed because most folks don't use goto.

> egcs-1.1b on RedHat 5.1.
> 
> #include <vector>
> 
> int
> main(int argc)
> {
>     goto done;
>     vector<int> t;
>   done:;
> }


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

* Re: warning not issued
  1998-10-21 22:10 ` Joe Buck
@ 1998-10-22 18:00   ` Martin von Loewis
  0 siblings, 0 replies; 4+ messages in thread
From: Martin von Loewis @ 1998-10-22 18:00 UTC (permalink / raw)
  To: jbuck; +Cc: tudor, egcs

> This is not legal C++; you can't jump around an initializer with a
> goto or a switch unless the initializer is inside curly braces.
> Just the same, the compiler should have caught it ... I'm sure this
> was missed because most folks don't use goto.

I think this is exactly the complaint. The compiler does catch cases
like

struct X{
  X();
};


main()
{
  goto a;
  X x;
  a: X y;
}

Bug reports should go to egcs-bugs@cygnus.com, though.

Regards,
Martin

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

* Re: warning not issued
  1998-10-21 13:42 warning not issued Tudor Hulubei
  1998-10-21 22:10 ` Joe Buck
@ 1998-10-30  3:25 ` Alexandre Oliva
  1 sibling, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 1998-10-30  3:25 UTC (permalink / raw)
  To: Tudor Hulubei; +Cc: egcs

[-- Attachment #1: Type: text/plain, Size: 374 bytes --]

Tudor Hulubei <tudor@cs.unh.edu> writes:

> The following code does not warn you that the initialization of `t' is
> skipped.

Thanks for your report, I installed the attached testcase to the
testsuite.

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:oliva@gnu.org mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil

[-- Attachment #2: init9.C --]
[-- Type: text/x-c, Size: 842 bytes --]

// Build don't link:

// Based on a testcase submitted by Tudor Hulubei <tudor@cs.unh.edu>

// X is not a POD because it has a user-defined destructor.
// Therefore, we can't cross its initialization.

// vector<int> is not even an aggregate; nevertheless, no error is
// reported...

struct A {
  A() {}
};

void a() {
  goto bar; // ERROR - jump from here
  A x; // ERROR - jump crosses initialization
 bar: // ERROR - jump to here
  ;
}

struct X {
  ~X() {}
};

void b() {
  goto bar; // ERROR - jump from here - XFAIL *-*-*
  X x; // ERROR - jump crosses initialization - XFAIL *-*-*
 bar: // ERROR - jump to here - XFAIL *-*-*
  ;
}

#include <vector>

void c() {
  goto bar; // ERROR - jump from here - XFAIL *-*-*
  vector<int> x; // ERROR - jump crosses initialization - XFAIL *-*-*
 bar: // ERROR - jump to here - XFAIL *-*-*
  ;
}

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

end of thread, other threads:[~1998-10-30  3:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-21 13:42 warning not issued Tudor Hulubei
1998-10-21 22:10 ` Joe Buck
1998-10-22 18:00   ` Martin von Loewis
1998-10-30  3:25 ` Alexandre Oliva

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).