Bug creation and email sending has been disabled, file new bugs at gcc.gnu.org/bugzilla
Bug 13 - ARM: can't cast _argptr / va_list to pointer
Summary: ARM: can't cast _argptr / va_list to pointer
Status: RESOLVED FIXED
Alias: None
Product: GDC
Classification: Unclassified
Component: gdc (show other bugs)
Version: development
Hardware: ARM Linux
: --- normal
Assignee: Johannes Pfau
URL:
Depends on:
Blocks:
 
Reported: 2012-09-25 12:00 CEST by Johannes Pfau
Modified: 2012-10-27 17:53 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Pfau 2012-09-25 12:00:24 CEST
----
import core.vararg;

void foo31(...)
{
    byte b = *cast(byte*)_argptr;
    assert(b == 8);
}

void main()
{
    byte b = 8;
    foo31(b);
}
----
test20.d: In function ‘foo31’:
test20.d:5: error: cannot convert to a pointer type

The test suite test cases runnable/test20.d and runnable/testdstress.d fail because of this. Should I document this as a difference between x86 and ARM and fix that test suite code to only run on x86? I guess this isn't portable code anyway?

Or should we somehow fix that in the compiler / druntime? AFAIK va_list is a structure on ARM, but it contains a void* which would probably work just like the va_list on x86?
Comment 1 Iain Buclaw 2012-09-25 20:31:59 CEST
ARM va_list type is void*
ARM EABI va_list type is {void*}

As such, you need to be a little more creative about getting it's value the x86-way.

byte *p = *cast(byte**)&argptr;
byte b = *p;

Works for both the old and embedded ABI's.
Comment 2 Johannes Pfau 2012-09-26 09:26:55 CEST
So D doesn't make any guarantees that casting va_list to a pointer is portable, right?

But what does that mean for the test suite? Change it to use the portable va_arg or is that test meant to be platform specific and we should add a version(ARM) block to test the ARM behaviour?

https://github.com/D-Programming-GDC/GDC/blob/master/gcc/testsuite/gdc.test/runnable/test20.d#L595
https://github.com/D-Programming-GDC/GDC/blob/master/gcc/testsuite/gdc.test/runnable/testdstress.d#L209
Comment 3 Iain Buclaw 2012-09-26 13:34:12 CEST
(In reply to comment #2)
> So D doesn't make any guarantees that casting va_list to a pointer is portable,
> right?
> 
> But what does that mean for the test suite? Change it to use the portable
> va_arg or is that test meant to be platform specific and we should add a
> version(ARM) block to test the ARM behaviour?
> 
> https://github.com/D-Programming-GDC/GDC/blob/master/gcc/testsuite/gdc.test/runnable/test20.d#L595
> https://github.com/D-Programming-GDC/GDC/blob/master/gcc/testsuite/gdc.test/runnable/testdstress.d#L209

Both look fishy... how it is passing for 64bit, I do not know.