Hi all, I know __builtin_va_list is target-specific, and ARM has typedef void* __builtin_va_list; X86 has typedef char* __builtin_va_list; It seems they can be treated as the same prototype,i.e.. void*, at the header level. What I want to ask is: If I write a program use "typedef *void** __builtin_va_list" on X86, and run it. Would I face any problem on run-time? I think it won't make any trouble. But I'm not very sure. Should anyone have similar experience? Thanks a lot. -- Best regards, Wen-Han -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110523/fa7c3c4d/attachment.html>
John McCall
2011-May-23 07:30 UTC
[LLVMdev] [cfe-dev] __builtin_va_list different on targets
On May 22, 2011, at 8:49 PM, Wenhan Gu wrote:> I know __builtin_va_list is target-specific, and > ARM has typedef void* __builtin_va_list; > X86 has typedef char* __builtin_va_list; > > > It seems they can be treated as the same prototype,i.e.. void*, at the header level. > What I want to ask is: > > If I write a program use "typedef void* __builtin_va_list" on X86, and run it. > Would I face any problem on run-time?C guarantees that void* and char* have compatible representations, so as long that's the only difference, you won't have runtime problems. You can obviously have compile-time problems, though: for example, in C, if va_list is a void*, then it can be implicitly converted to any pointer type instead of (as with char*) only explicitly converted; and in C++, you can get different manglings, which is actually how we found out that our ARM target was misdeclaring it. But otherwise it should be fine, as long as that's the only difference. However, other targets may have more complicated differences than just void* vs. char*. John. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110523/65f5f191/attachment.html>
Wenhan Gu
2011-May-23 07:43 UTC
[LLVMdev] [cfe-dev] __builtin_va_list different on targets
Thanks for your answer very much. I wonder for what reason does ARM use *void ** but X86 use *char ** ? Seems ARM uses void * since its spec said that. But X86? I cannot find any reason or spec to specify why X86 uses char *, not void * directly? Could anyone give me some hints? Thanks a lot. 2011/5/23 John McCall <rjmccall at apple.com>> On May 22, 2011, at 8:49 PM, Wenhan Gu wrote: > > I know __builtin_va_list is target-specific, and > ARM has typedef void* __builtin_va_list; > X86 has typedef char* __builtin_va_list; > > It seems they can be treated as the same prototype,i.e.. void*, at the > header level. > What I want to ask is: > > If I write a program use "typedef *void** __builtin_va_list" on X86, and > run it. > Would I face any problem on run-time? > > > C guarantees that void* and char* have compatible representations, so > as long that's the only difference, you won't have runtime problems. > You can obviously have compile-time problems, though: for example, > in C, if va_list is a void*, then it can be implicitly converted to any > pointer > type instead of (as with char*) only explicitly converted; and in C++, you > can get different manglings, which is actually how we found out that our > ARM target was misdeclaring it. But otherwise it should be fine, as long > as that's the only difference. > > However, other targets may have more complicated differences than > just void* vs. char*. > > John. >-- Best regards, Wen-Han -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110523/5b4417f5/attachment.html>
Maybe Matching Threads
- [LLVMdev] [cfe-dev] __builtin_va_list different on targets
- [LLVMdev] [cfe-dev] __builtin_va_list different on targets
- [LLVMdev] Could LLVM or Clang go backward to modify c source code?
- [LLVMdev] Data flow analysis
- [LLVMdev] Does someone still keep eye on MC ARM EHABI?