Daniel Liew
2013-Aug-15 15:30 UTC
[LLVMdev] Clarification between <type> and <ty> for alloca instruction
On 15/08/13 16:12, Tim Northover wrote:>> I've obviously being playing with C++ too long because my >> instinct immediately told me that dynamically sized arrays on >> the stack are't allowed but apparently that's fine for C99 (g++ >> also seems fine with this is you don't specify -pedantic) > > It's all fun and games until someone decides to evaluate > sizeof(arr). ;-) > > I think a more limited form is coming to C++11, by the way. > >> Interesting thanks for clarifying. Now you've raised another >> question. I'm interested to know how you know that this is how >> overflow behaves for this particular instruction. I can imagine >> several different behaviours (I'm assuming NumElements is >> unsigned but that doesn't seem to be specified) >> >> - wrap around overflow. In which case 257 = 255 + 2 so result >> would be 2 > > This is what happens (wraparound/truncation/whatever). But I think > 256 -> 0, 257 -> 1.Oops yes you're completely right. I didn't think about that through very well ( I was doing % 255 in my head instead of % 256). Do you think it would be wise to document the meaning of <ty> for the alloca instruction or do you think that it is clear enough and that it is my unfamiliarity with LLVM IR that caused my confusion? Thanks, Dan.
Tim Northover
2013-Aug-15 16:02 UTC
[LLVMdev] Clarification between <type> and <ty> for alloca instruction
> Do you think it would be wise to document the meaning of <ty> for the > alloca instruction or do you think that it is clear enough and that it > is my unfamiliarity with LLVM IR that caused my confusion?Personally I'd say it's clear enough, but others may disagree. Cheers. Tim.
Possibly Parallel Threads
- [LLVMdev] Clarification between <type> and <ty> for alloca instruction
- [LLVMdev] Clarification between <type> and <ty> for alloca instruction
- [LLVMdev] Clarification between <type> and <ty> for alloca instruction
- [LLVMdev] malloc(), free(), and alloca() with zero size
- [LLVMdev] Question concerning alloca