Hi Michael --

I think it's our intention to follow C99's lead here and that the lack of 
mention of it in the spec is an oversight.  If you want to contribute a patch 
to update the spec before the doc freeze on Friday, that'd be great.  Saw your 
bug fix patch in the other mail, but haven't had a chance to open that up yet 
(and may not today -- am hoping someone else has a cleaner desk going into the 
code freeze than me).

-Brad

________________________________________
From: Michael Ferguson [[email protected]]
Sent: Monday, March 31, 2014 7:37 AM
To: chapel-developers
Subject: [Chapel-developers] cast-to-bool

Hi -

meteor.chpl uses cast-to-bool from an integer expression,
like this test code does:

proc foo(x:uint, y:uint)
{
   writeln((x & y):bool);
}

writeln((0x3 & 0x1):bool);
foo(0x3, 0x1);
writeln((0x300 & 0x100):bool);
foo(0x300, 0x100);


I don't see anything in the spec about conversions
*from* uint/int to bool; I'd expect to see that in
section 9.2.1.

So - that begs the question - what is such a program
actually supposed to do?

C99 says "When any scalar value is converted to
_Bool, the result is 0 if the value compares equal
to 0; otherwise, the result is 1"

It appears that our generated C code uses _Bool and
so works in this manner... and that the Chapel
implementation of cast-to-bool for param expressions
also works in this manner.

The LLVM backend does *not* work in this manner..
which I believe is a bug. Either way, the expected behavior
should be documented in the spec.

Thanks,

-michael

------------------------------------------------------------------------------
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

------------------------------------------------------------------------------
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to