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


Groups > comp.lang.c > #23446

Re: What shall return "0.0 ? 1 : 0" ?

From jacob navia <jacob@spamsink.net>
Newsgroups comp.lang.c
Subject Re: What shall return "0.0 ? 1 : 0" ?
Date 2012-07-20 18:15 +0200
Organization lccwin
Message-ID <juc075$sku$1@speranza.aioe.org> (permalink)
References <jubm08$k38$1@news.httrack.net>

Show all headers | View raw


Le 20/07/12 15:21, Xavier Roche a écrit :
> Hi folks!
>
> Is there a C standard expert who can confirm what shall return
>      0.0 ? 1 : 0
>
> With gcc 4.3/Linux, the result is 0. With Visual C++2010, the result
> is.. 1.
>
> Is the result undefined by the standard, by chance ?
>
>
> Regards,
> Xavier Roche

The bug is at the level of the compile-time interpretation since the 
result is not calculated at run time (even without aptimizations!)

cl -FA bug.c yields this code:

; Listing generated by Microsoft (R) Optimizing Compiler Version 
16.00.30319.01

include listing.inc

INCLUDELIB LIBCMT
INCLUDELIB OLDNAMES

_DATA   SEGMENT
$SG2584 DB      '???', 00H
         ORG $+4
$SG2585 DB      '0.0 ? ??? : OK = %s', 0aH, 00H
_DATA   ENDS
PUBLIC  main
EXTRN   printf:PROC
pdata   SEGMENT
$pdata$main DD  imagerel $LN3
         DD      imagerel $LN3+30
         DD      imagerel $unwind$main
pdata   ENDS
xdata   SEGMENT
$unwind$main DD 010401H
         DD      04204H
; Function compile flags: /Odtp
xdata   ENDS
_TEXT   SEGMENT
main    PROC
; File d:\lcc\bug.c
; Line 3
$LN3:
         sub     rsp, 40                                 ; 00000028H
; Line 4
         lea     rdx, OFFSET FLAT:$SG2584
         lea     rcx, OFFSET FLAT:$SG2585
         call    printf
; Line 5
         xor     eax, eax
         add     rsp, 40                                 ; 00000028H
         ret     0
main    ENDP
_TEXT   ENDS
END

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


Thread

What shall return "0.0 ? 1 : 0" ? Xavier Roche <xroche@free.fr.NOSPAM.invalid> - 2012-07-20 15:21 +0200
  Re: What shall return "0.0 ? 1 : 0" ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-07-20 14:57 +0100
    Re: What shall return "0.0 ? 1 : 0" ? Tim Rentsch <txr@alumni.caltech.edu> - 2012-07-21 14:39 -0700
      Re: What shall return "0.0 ? 1 : 0" ? Ralf Damaschke <rwspam@gmx.de> - 2012-07-21 23:31 +0000
        Re: What shall return "0.0 ? 1 : 0" ? Tim Rentsch <txr@alumni.caltech.edu> - 2012-07-21 21:57 -0700
          Re: What shall return "0.0 ? 1 : 0" ? Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-07-22 17:27 +0300
            Re: What shall return "0.0 ? 1 : 0" ? Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-07 11:15 -0700
          Re: What shall return "0.0 ? 1 : 0" ? Martin Shobe <martin.shobe@yahoo.com> - 2012-07-22 18:43 +0000
            Re: What shall return "0.0 ? 1 : 0" ? Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-07 10:14 -0700
          Re: What shall return "0.0 ? 1 : 0" ? Ralf Damaschke <rwspam@gmx.de> - 2012-07-22 22:43 +0000
            Re: What shall return "0.0 ? 1 : 0" ? Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-07 10:59 -0700
      Re: What shall return "0.0 ? 1 : 0" ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-07-22 02:43 +0100
        Re: What shall return "0.0 ? 1 : 0" ? Tim Rentsch <txr@alumni.caltech.edu> - 2012-07-21 22:05 -0700
      Re: What shall return "0.0 ? 1 : 0" ? Seungbeom Kim <musiphil@bawi.org> - 2012-07-22 03:20 -0700
        Re: What shall return "0.0 ? 1 : 0" ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-07-22 14:25 +0100
          Re: What shall return "0.0 ? 1 : 0" ? "Bill Leary" <Bill_Leary@msn.com> - 2012-07-22 18:56 -0400
            Re: What shall return "0.0 ? 1 : 0" ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-07-23 01:37 +0100
              Re: What shall return "0.0 ? 1 : 0" ? "Bill Leary" <Bill_Leary@msn.com> - 2012-07-23 07:27 -0400
            Re: What shall return "0.0 ? 1 : 0" ? Ike Naar <ike@sverige.freeshell.org> - 2012-07-23 06:45 +0000
              Re: What shall return "0.0 ? 1 : 0" ? "Bill Leary" <Bill_Leary@msn.com> - 2012-07-23 07:37 -0400
          Re: What shall return "0.0 ? 1 : 0" ? Ike Naar <ike@sverige.freeshell.org> - 2012-07-23 06:49 +0000
            Re: What shall return "0.0 ? 1 : 0" ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-07-23 12:42 +0100
  Re: What shall return "0.0 ? 1 : 0" ? Noob <root@127.0.0.1> - 2012-07-20 15:58 +0200
    Re: What shall return "0.0 ? 1 : 0" ? Xavier Roche <xroche@free.fr.NOSPAM.invalid> - 2012-07-20 16:02 +0200
      Re: What shall return "0.0 ? 1 : 0" ? Noob <root@127.0.0.1> - 2012-07-20 16:22 +0200
        Re: What shall return "0.0 ? 1 : 0" ? Xavier Roche <xroche@free.fr.NOSPAM.invalid> - 2012-07-20 16:26 +0200
          Re: What shall return "0.0 ? 1 : 0" ? Kenneth Brody <kenbrody@spamcop.net> - 2012-07-20 15:11 -0400
          Re: What shall return "0.0 ? 1 : 0" ? Robert Miles <milesrf@Usenet-News.net> - 2012-08-25 00:16 -0500
      Re: What shall return "0.0 ? 1 : 0" ? Kenneth Brody <kenbrody@spamcop.net> - 2012-07-20 15:10 -0400
  Re: What shall return "0.0 ? 1 : 0" ? jacob navia <jacob@spamsink.net> - 2012-07-20 18:15 +0200
  Re: What shall return "0.0 ? 1 : 0" ? Keith Thompson <kst-u@mib.org> - 2012-07-20 09:51 -0700
    Re: What shall return "0.0 ? 1 : 0" ? pete <pfiland@mindspring.com> - 2012-07-20 20:29 -0400
      Re: What shall return "0.0 ? 1 : 0" ? Keith Thompson <kst-u@mib.org> - 2012-07-20 20:25 -0700
        Re: What shall return "0.0 ? 1 : 0" ? Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-07-21 22:22 +0300
        Re: What shall return "0.0 ? 1 : 0" ? Tim Rentsch <txr@alumni.caltech.edu> - 2012-07-21 14:54 -0700
    Re: expressions, evaluations, and values (was: What shall return "0.0 ? 1 : 0" ?) Tim Rentsch <txr@alumni.caltech.edu> - 2012-07-21 14:52 -0700
  Re: What shall return "0.0 ? 1 : 0" ? Keith Thompson <kst-u@mib.org> - 2012-07-20 10:08 -0700

csiph-web