public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* C std question: while loop with two tests.
@ 2013-05-06 15:34 Steve Ellcey 
  2013-05-06 15:57 ` Marc Glisse
       [not found] ` <CAMWMY7w4Dp2=ns9m+4Ey=fxQ33v24Qaue59N6QRdKNeSQ2mx_w@mail.gmail.com>
  0 siblings, 2 replies; 3+ messages in thread
From: Steve Ellcey  @ 2013-05-06 15:34 UTC (permalink / raw)
  To: gcc-help


I was using delta to cutdown a program and wound up with something like this.
Is this really legal C?  GCC doesn't complain about it.

    int foo(int x)
    {
	while (1)
	{
	    if (x > 0) continue;
	} while (0);
    }

Steve Ellcey
sellcey@imgtec.com

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

* Re: C std question: while loop with two tests.
  2013-05-06 15:34 C std question: while loop with two tests Steve Ellcey 
@ 2013-05-06 15:57 ` Marc Glisse
       [not found] ` <CAMWMY7w4Dp2=ns9m+4Ey=fxQ33v24Qaue59N6QRdKNeSQ2mx_w@mail.gmail.com>
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Glisse @ 2013-05-06 15:57 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: gcc-help

On Mon, 6 May 2013, Steve Ellcey  wrote:

> I was using delta to cutdown a program and wound up with something like this.
> Is this really legal C?  GCC doesn't complain about it.

Let me reformat it a bit:

int foo(int x)
{
   while (1)
   {
     if (x > 0) continue;
   }

   while (0)
   ;
}

(missing a return maybe?)

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

* Re: C std question: while loop with two tests.
       [not found] ` <CAMWMY7w4Dp2=ns9m+4Ey=fxQ33v24Qaue59N6QRdKNeSQ2mx_w@mail.gmail.com>
@ 2013-05-06 15:57   ` Steve Ellcey
  0 siblings, 0 replies; 3+ messages in thread
From: Steve Ellcey @ 2013-05-06 15:57 UTC (permalink / raw)
  To: Anupam Chahar; +Cc: gcc-help

On Mon, 2013-05-06 at 17:48 +0200, Anupam Chahar wrote:
> It has two different while loops
> I guess it will break down into this:
> 
> 
> int foo(int x)
> {
>       while (1)
>       {
>           if (x>0) continue;
>        }
> 
> 
>        while(0);
> }
> 
> 
> So it is correct

> 
> 
> -- 
> Anupam Chahar

Thanks, that makes sense now.

Steve Ellcey
sellcey@imgtec.com




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

end of thread, other threads:[~2013-05-06 15:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-06 15:34 C std question: while loop with two tests Steve Ellcey 
2013-05-06 15:57 ` Marc Glisse
     [not found] ` <CAMWMY7w4Dp2=ns9m+4Ey=fxQ33v24Qaue59N6QRdKNeSQ2mx_w@mail.gmail.com>
2013-05-06 15:57   ` Steve Ellcey

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