This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] Improve the old fix for 11095


On Fri, 10 Oct 2003 18:16:07 +0200, Paolo Carlini <pcarlini@unitus.it> wrote:

> Benjamin Kosnik wrote:
>
>> This use of __builtin_alloca is wrong... 	      if (__w > __len)
>>  		{
>>! 		  __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
>>! 							       * __w));
>> ! 		  __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __cs,
>> &__c, __w, __len, false);
>>  		  __len = __w;
>>  		}
>>! 	      __out._M_write(__cs, __len);
>>
>>
>>__cs is only valid in the scope of the if block, but is used outside of
>>it (in __out._M_write(__cs, __len).
>>
> Benjamin, I'm not sure to understand what you mean... To my best knowledge,
> memory allocated with __builtin_alloca, or plain 'alloca' for that matter,
> is freed at the end of the /function/ not at the end of the block! The glibc
> info pages are very clear about that!

Yes.  Only VLAs are freed at the end of the block.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]