gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

openbsd macppc clang broken va_args(_, id)


From: Anthony Richardby
Subject: openbsd macppc clang broken va_args(_, id)
Date: Sat, 10 Oct 2020 22:46:33 +0100
User-agent: GNUMail (Version 1.3.0)

Hi,
I've been trying to get GNUstep up and running on my powerpc setup for
a little while, and
I figure this is the best place to ask for advice, or if anybody knows
some trick I'm not aware of!

The problem:
Using 'va_arg()' with type 'id' just doesn't work, you certainly don't
get back the arguments to
the function, at least. For example, consider the following program:

#include <stdio.h>
#include <Foundation/Foundation.h>

id test(id first, ...) {
        va_list ap;
        id second, third;

        va_start(ap, first);
        second = va_arg(ap, id);
        third = va_arg(ap, id);
        return third;
}


int main(int argc, char **argv) {
        NSString *str1 = @"test1";
        NSString *str2 = @"test2";
        NSString *str3 = @"test3";

        id res = test(str3, str2, str3);
        printf("%x\n", res);
        if (str3 == res) {
                printf("works\n");
        } else {
                printf("broken\n");
        }
        return 0;
}

When run, this prints out:

netty$ ./obj/Hello
0
broken

And actually, debugging this shows that va_arg is returning the same
data each for 'second'
and 'third'.

Breakpoint 1, test (first=0x382b48f8) at main.m:11
11              return third;
Current language:  auto; currently minimal
(gdb) p first
$1 = 0x382b48f8
(gdb) p second
$2 = 0x3fe00000
(gdb) p third
$3 = 0x0
(gdb)

'second' and 'third' are always 0x3fe00000, and 0x0 on every single
run.

Replacing 'va_arg(ap, id)' with 'va_arg(ap, void*)' makes the program
run as exected.
Outputing:
netty$ ./obj/Hello
1e5a4910
works

For the moment, I've got everything working just by replacing all
occurrances of 'id' when used with
va_arg with 'void*'. And everything seems to work just fine. The funny
thing is, this seems to be
specific to 'id' - is it given special treatment somehow?

I'm running OpenBSD 6.7, building from a slightly modified ports tree
(it's disabled on macppc
by default) CC/CXX is set to base clang.

Anyone got ideas what's going on here?

Cheers,
Anthony.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]