Le dimanche 29 juin 2014, 21:38:33 Carlos Montiers a écrit :
> Hello.
> I requesting memory from the stack using the function alloca.
> I know that the use of it is discourage, but I want use it anyways.
> 
> I write a code for windows that use it and I tested ok, but only when I
> compile with gcc. Compiling it with tiny c fails, the program crash.
> Maybe is a bug of tiny c.

I assume that your program is compiled on Windows 64 bits, given the alloca 
(INT_MAX). The definition of alloca for Windows 64 bits is in 
lib/alloca86_64.S. When the parameter is bigger than 4096, then it will do a 
loop that allocates 4096 bytes on the stack, read a value on the stack and 
start all over again until all the space asked is allocated. I suppose that 
the goal of the read is to make Windows actually allocate the space to avoid 
an error if a big alloca is made.

I don't know for Windows but on Linux nothing is allocated as long as nothing 
is written. So a big alloca would do nothing and then writing a bit structure 
on the stack would fail as it would make the stack grow too quickly. I guess 
that's what is happening here. Try to reduce the amount given to alloca (Try 
8192 for instance).

Best regards,

Thomas

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to