Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #20934

Re: Segmentation Fault

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: Segmentation Fault
Date 2012-05-17 16:59 -0400
Organization A noiseless patient Spider
Message-ID <4FB566A2.7060004@verizon.net> (permalink)
References <jorcqt$72h$1@speranza.aioe.org> <slrn3vfsjr82qi.jba.ike@sverige.freeshell.org> <jp3kqq$cbt$1@speranza.aioe.org>

Show all headers | View raw


On 05/17/2012 03:50 PM, pembed2012 wrote:
> On Wed, 16 May 2012 20:17:22 +0000, Ike Naar wrote:
> 
>> On 2012-05-14, pembed2012 <once@was.enough.invalid> wrote:
>>>       if(ctm[qu[i]] == 0);
>>
>> This statement is redundant (it's an if statement with an empty body).
>> Elsethread, you say that the code was written by a "genius programmer"
>> and is super efficient. Including a redundant statement is not what one
>> would expect from such a programmer. Is the code that you posted the
>> real, unmodified code?
> 
> The only thing I can think of is, maybe the condition is being evaluated 
> for its side effects.

Side effects can only result from ++, --, assignment expressions,
certain function calls, or accessing a volatile object. None of those
things happen in this code, so that can't be the reason.

> Of course it may be a bug. How does the behavior of the code change if 
> you delete the ; ?

In the original code, it said:

	if(ctm[qu[i]] == 0);
	atm[qu[i]] = -1;

That's exactly equivalent to

	atm[qu[i]] = -1;

Removing the semicolon would change the code so that it was equivalent to
	if(ctm[qu[i]] == 0)
	{
            atm[qu[i]] = -1;
	}

which is very different.

> I don't feel like I've had a clear answer yet about what this function is 
> doing and how it works!

You haven't, because you've been asking the wrong people. Is there
anyone who's ever written code that uses this function that you can talk to?

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Segmentation Fault pembed2012 <once@was.enough.invalid> - 2012-05-14 16:45 +0000
  Re: Segmentation Fault John Gordon <gordon@panix.com> - 2012-05-14 17:00 +0000
    Re: Segmentation Fault Keith Thompson <kst-u@mib.org> - 2012-05-14 13:44 -0700
      Re: Segmentation Fault Edward Rutherford <edward.p.rutherford79@REMOVETHIS.gmail.com> - 2012-05-14 21:07 +0000
        Re: Segmentation Fault John Gordon <gordon@panix.com> - 2012-05-14 21:10 +0000
  Re: Segmentation Fault James Kuyper <jameskuyper@verizon.net> - 2012-05-14 13:25 -0400
    Re: Segmentation Fault pembed2012 <once@was.enough.invalid> - 2012-05-14 21:00 +0000
      Re: Segmentation Fault James Kuyper <jameskuyper@verizon.net> - 2012-05-14 17:21 -0400
      Re: Segmentation Fault John Gordon <gordon@panix.com> - 2012-05-14 21:24 +0000
        Re: Segmentation Fault John Gordon <gordon@panix.com> - 2012-05-14 21:35 +0000
        Re: Segmentation Fault pembed2012 <once@was.enough.invalid> - 2012-05-15 19:27 +0000
          Re: Segmentation Fault "BartC" <bc@freeuk.com> - 2012-05-15 20:38 +0100
            Re: Segmentation Fault pembed2012 <once@was.enough.invalid> - 2012-05-16 19:56 +0000
              Re: Segmentation Fault James Kuyper <jameskuyper@verizon.net> - 2012-05-16 16:17 -0400
              Re: Segmentation Fault James Kuyper <jameskuyper@verizon.net> - 2012-05-16 16:17 -0400
          Re: Segmentation Fault John Gordon <gordon@panix.com> - 2012-05-15 19:56 +0000
          Re: Segmentation Fault James Kuyper <jameskuyper@verizon.net> - 2012-05-15 15:58 -0400
            Re: Segmentation Fault Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-05-18 01:02 +0000
          Re: Segmentation Fault Kaz Kylheku <kaz@kylheku.com> - 2012-05-15 20:10 +0000
            Re: Segmentation Fault lawrence.jones@siemens.com - 2012-05-15 17:43 -0400
              Re: Segmentation Fault James Kuyper <jameskuyper@verizon.net> - 2012-05-15 18:27 -0400
            Re: Segmentation Fault gordonb.dxbbb@burditt.org (Gordon Burditt) - 2012-05-19 02:37 -0500
  Re: Segmentation Fault "BartC" <bc@freeuk.com> - 2012-05-14 22:17 +0100
  Re: Segmentation Fault Fred K <fred.l.kleinschmidt@gmail.com> - 2012-05-14 10:02 -0700
  Re: Segmentation Fault Fred K <fred.l.kleinschmidt@gmail.com> - 2012-05-14 11:33 -0700
  Re: Segmentation Fault Ike Naar <ike@sverige.freeshell.org> - 2012-05-16 20:17 +0000
    Re: Segmentation Fault nick_keighley_nospam@hotmail.com - 2012-05-17 03:05 -0700
      Re: Segmentation Fault Ike Naar <ike@iceland.freeshell.org> - 2012-05-17 11:07 +0000
    Re: Segmentation Fault pembed2012 <once@was.enough.invalid> - 2012-05-17 19:50 +0000
      Re: Segmentation Fault James Kuyper <jameskuyper@verizon.net> - 2012-05-17 16:59 -0400
      Re: Segmentation Fault Ike Naar <ike@sverige.freeshell.org> - 2012-05-18 07:22 +0000

csiph-web