RetroBSD

2.11BSD operating system for microcontrollers
It is currently Thu Jun 27, 2019 2:56 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: va_arg failure?
PostPosted: Mon Jan 11, 2016 6:22 am 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
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)

_________________
@__briancallahan on Twitter


Top
 Profile  
 
 Post subject: Re: va_arg failure?
PostPosted: Mon Jan 11, 2016 7:26 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
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.

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
 Post subject: Re: va_arg failure?
PostPosted: Mon Jan 11, 2016 7:48 am 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
No. Please read the code.

_________________
@__briancallahan on Twitter


Top
 Profile  
 
 Post subject: Re: va_arg failure?
PostPosted: Mon Jan 11, 2016 3:48 pm 
Contributor

Joined: Mon Nov 12, 2012 1:34 pm
Posts: 1092
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


Top
 Profile  
 
 Post subject: Re: va_arg failure?
PostPosted: Mon Jan 11, 2016 5:51 pm 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
Not sure why it doesn't work on RetroBSD. alexfru might be able to shed some light on that.
This code is for LiteBSD.

_________________
@__briancallahan on Twitter


Top
 Profile  
 
 Post subject: Re: va_arg failure?
PostPosted: Mon Jan 11, 2016 7:10 pm 
Contributor

Joined: Mon Apr 29, 2013 1:56 am
Posts: 196
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. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron




Powered by phpBB® Forum Software © phpBB Group

BSD Daemon used with permission