Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"It's God. No, not Richard Stallman, or Linus Torvalds, but God." (By Matt Welsh)


devel / comp.std.c / Re: Is the output of this program compiler dependent?

SubjectAuthor
* Is the output of this program compiler dependent?Satan
`- Re: Is the output of this program compiler dependent?Richard Damon

1
Is the output of this program compiler dependent?

<ss2nci$a2k$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=439&group=comp.std.c#439

  copy link   Newsgroups: comp.std.c
Path: i2pn2.org!i2pn.org!aioe.org!bU2I7+U2Lztfeei1gwcHPg.user.46.165.242.91.POSTED!not-for-mail
From: sat...@dot.com (Satan)
Newsgroups: comp.std.c
Subject: Is the output of this program compiler dependent?
Date: Mon, 17 Jan 2022 03:00:00 +0000
Organization: Aioe.org NNTP Server
Message-ID: <ss2nci$a2k$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="10324"; posting-host="bU2I7+U2Lztfeei1gwcHPg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Satan - Mon, 17 Jan 2022 03:00 UTC

I read somewhere that the parameters of functions are evaluated right >>
to left but it all depends on the compiler. Therefore, does this mean
that the output of this program is "undefined" meaning there is no
definite answer!

#include <stdio.h>

void fun(int, int);

int main()
{ int i = 5;
fun(--i, i++);
fun(++i, i--);
printf("From Main: %d\n", i++);

return 0;
}

void fun(int x, int y)
{ printf("From Function: %d %d\n", x++, y--);
}

Re: Is the output of this program compiler dependent?

<X56FJ.6201$rQ.6013@fx18.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=440&group=comp.std.c#440

  copy link   Newsgroups: comp.std.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx18.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.5.0
Subject: Re: Is the output of this program compiler dependent?
Content-Language: en-US
Newsgroups: comp.std.c
References: <ss2nci$a2k$1@gioia.aioe.org>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <ss2nci$a2k$1@gioia.aioe.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 37
Message-ID: <X56FJ.6201$rQ.6013@fx18.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 16 Jan 2022 23:18:02 -0500
X-Received-Bytes: 2004
X-Original-Bytes: 1871
 by: Richard Damon - Mon, 17 Jan 2022 04:18 UTC

On 1/16/22 10:00 PM, Satan wrote:
> I read somewhere that the parameters of functions are evaluated right >>
> to left but it all depends on the compiler. Therefore, does this mean
> that the output of this program is "undefined" meaning there is no
> definite answer!
>
> #include <stdio.h>
>
> void fun(int, int);
>
> int main()
> {
> int i = 5;
> fun(--i, i++);
> fun(++i, i--);
> printf("From Main: %d\n", i++);
>
> return 0;
> }
>
> void fun(int x, int y)
> {
> printf("From Function: %d %d\n", x++, y--);
> }

Yes, there is no sequencing between the evaluation of the various
parameters to the function, to those calls invoke undefined behavior.

Implementations might give additional promises, but that is beyond the
control of the standard, and there may be a 'normal' order they follow,
but that still doesn't make it a requirement, and you might get burned
by a case where the implementation did it different in some case because
of ...reasons... so do go by what seems to work.

Remember, doing what you expected is perfectly fine possible undefined
behavior, but you shouldn't count on it.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor