Chuck -

        I can reproduce your findings and I too
think Cil does not follow the C-standard here,
though IMHO the relevant part is not 7.15.1.1:2,
but 6.5.2.2:7.  Also see: Harbison/Steele
Sec. 6.3.5.


On Thu, May 20, 2010 at 12:10:49PM -0500, Chucky Ellison wrote:
> The work that I am doing relies on promotions being explicit, so this is
> important to me.  Is the intention to support these promotions?

        I expanded your example a little bit, so
that we can see how Cil behaves in all of the
cases:
(i) foo: Your original function prototype
     _with_ ellipses;
(ii) bar: A prototype that matches the
     call site of foo w/o ellipses and
     matching parameter types;
(iii) baz: A prototype that matches the
     call site of foo w/o ellipses and
     parameter types as expected for function
     argument conversion (i.e. "usual unary
     conversions" and, in addition, float ->
     double);


        int foo(int x, ...);
        int bar(int x, char c, short int si, int i, long int li, long long int 
lli, float f);
        int baz(int x, int c, int si, int i, long int li, long long int lli, 
double f);

        int main(void)
        {
            char c = 5;
            short int si = 10;
            float f = 30.0;

            foo(0, c, si, 15, 20L, 25LL, f);
            bar(0, c, si, 15, 20L, 25LL, f);
            baz(0, c, si, 15, 20L, 25LL, f);

            return 0;
        }


The invocation
        cilly.byte --out variarg.cil.c variarg.c
produces the following code for the three
function calls:

        foo(0, c, si, 15, 20L, 25LL, f);
        bar(0, c, si, 15, 20L, 25LL, f);
        baz(0, (int )c, (int )si, 15, 20L, 25LL, (double )f);


> If so, perhaps I am somehow disabling these inadvertently?  Is my
> understanding of the C spec incorrect?  I appreciate any
> information/advice you can provide.

        I don't think you are "disabling these
inadvertently", but I do think Cil does not
treat the actual parameters correctly in the
call to foo (whereas the calls to foo and baz
are correct).  In my opinion -- which is based
on 7.15.1.1:2 -- you have spotted a bug.


/Chris

------------------------------------------------------------------------------

_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to