https://bugs.llvm.org/show_bug.cgi?id=47921

            Bug ID: 47921
           Summary: va_arg() with type 'id' produces incorrect output
           Product: clang
           Version: 8.0
          Hardware: Other
                OS: OpenBSD
            Status: NEW
          Keywords: compile-fail
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangb...@nondot.org
          Reporter: antho...@gmx.co.uk
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

Created attachment 24084
  --> https://bugs.llvm.org/attachment.cgi?id=24084&action=edit
This reproduces the bug, compile with -DUSE_HACK to apply the workaround
mentioned.

When I use va_arg, providing type 'id', the return values are incorrect.
In the source code I have attached, I have a function taking a variable number
of arguments of type 'id', I pass in 3 arguments, and return the third out of
it. The value of this third agument returned should be equal to the third
argument passed in. However it is not.

When I instead change the type passed to va_arg() to 'void*', (I guess this
works as they're both the same size?), I get the expected result. 

I've tried to boil my example code down to demonstrate it as simple as
possible, however this behavior is present when I try to use the GNUstep system
too, and indeed the 'fix' of replacing occurances of va_arg(*, id) with
va_arg(*, void*) results in a completely stable system.

Here's an example shell session using the code I have attached:
netty$ cc bug.m -o bug
netty$ ./bug
netty$ echo $?
1
netty$ cc -DUSE_HACK bug.m -o bug
netty$ ./bug
netty$ echo $?
0

netty$ cc -v
OpenBSD clang version 8.0.1 (tags/RELEASE_801/final) (based on LLVM 8.0.1)
Target: powerpc-unknown-openbsd6.7
Thread model: posix
InstalledDir: /usr/bin

netty$ uname -a
OpenBSD netty.my.domain 6.7 GENERIC#714 macppc

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to