RetroBSD
http://retrobsd.org/

va_arg failure?
http://retrobsd.org/viewtopic.php?f=16&t=37485
Page 1 of 1

Author:  ibara [ Mon Jan 11, 2016 6:22 am ]
Post subject:  va_arg failure?

Hi team --

Trying to do some debugging of pcc, found some code that even gcc doesn't compile correctly. It originally comes from the gcc mailing list: https://gcc.gnu.org/ml/gcc-bugs/2000-01/msg00696.html
The code in question is available here: https://devio.us/~bcallah/vtest.tgz (you can drop it into the contrib/ directory and run bmake for easy compilation)

For comparison, on NetBSD/i386, it does the right thing:
Code:
*
* Simple stdarg test.
*
  # of args:6
       int: expected: -1,      passed: -1
      char: expected:  2,      passed:  2
 long long: expected: -3,      passed: -3
    string: expected:  4,      passed:  4
       int: expected: -5,      passed: -5
      char: expected:  6,      passed:  6
OK


Here's the code when run on LiteBSD, compiled with gcc:
Code:
*
* Simple stdarg test.
*
  # of args:6
       int: expected: -1,      passed: -1
      char: expected:  2,      passed:  0
 long long: expected: -3,      passed: -1
    string: expected:  4,      passed:  0
       int: expected: -5,      passed: -1
      char: expected:  6,      passed:  0
OK

(Yes, it really offers an OK even though it fails.)

And finally, here's the same code on LiteBSD, compiled with pcc:
Code:
*
* Simple stdarg test.
*
  # of args:6
       int: expected:  0,      passed:  0
      char: expected:  2,      passed:  0
 long long: expected:  0,      passed:  0
    string: expected:  4,      passed:  0
       int: expected:  0,      passed:  0
      char: expected:  6,      passed:  0
NG

(NG = no good)

Author:  Pito [ Mon Jan 11, 2016 7:26 am ]
Post subject:  Re: va_arg failure?

viewtopic.php?f=16&t=37324&p=42295&hilit=va_arg#p42295
Quote:
It makes sense to replace varargs.h with stdarg.h - everywhere, not only in init.c.

Author:  ibara [ Mon Jan 11, 2016 7:48 am ]
Post subject:  Re: va_arg failure?

No. Please read the code.

Author:  wiz [ Mon Jan 11, 2016 3:48 pm ]
Post subject:  Re: va_arg failure?

Hi Brian,

Nice. As I said quite a bit earlier, I always wondered why I mistrusted compilers....

I did cc vtest.c on this knoppix 7.2.0 box. Got the right answers :).

Haven't tried it on my retro box yet.

Just did. No Go. complains:

Error in "vtest.c" (9:11)

Unexpected token long

I guess whatever version of smlrc doesn't like long :(.

I 'should' upgrade except all my stuff would stop working since I have a few mods in my kernel....

Which RetroBSD compiler do you 'recommend' !! :)

Lots of fun.

Wiz

Author:  ibara [ Mon Jan 11, 2016 5:51 pm ]
Post subject:  Re: va_arg failure?

Not sure why it doesn't work on RetroBSD. alexfru might be able to shed some light on that.
This code is for LiteBSD.

Author:  alexfru [ Mon Jan 11, 2016 7:10 pm ]
Post subject:  Re: va_arg failure?

wiz wrote:
Nice. As I said quite a bit earlier, I always wondered why I mistrusted compilers....

I did cc vtest.c on this knoppix 7.2.0 box. Got the right answers :).

Haven't tried it on my retro box yet.

Just did. No Go. complains:

Error in "vtest.c" (9:11)

Unexpected token long

I guess whatever version of smlrc doesn't like long :(.


Smaller C does not implement numeric types larger than the machine word. long long must be 64-bit, which is two machine words. I'm working on supporting floating point in the compiler and there's gonna be the same limitation. double will be an alias for float, that is, 32-bit single precision only. Btw, there was no long long in the days of 2.11BSD. long long appeared in the language in 1999. :)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/