Like Tree9Likes

How bad is it to use alloca()?

This is a discussion on How bad is it to use alloca()? within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by MutantJohn ...I wasn't genuinely upset and Elysia, I hope you're not either... Worry not. I was in ...

  1. #46
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,013
    Quote Originally Posted by MutantJohn View Post
    ...I wasn't genuinely upset and Elysia, I hope you're not either...
    Worry not. I was in a playful mood when responding to your posts, which I assumed too since your post about linux seemed more sarcasm then realism to me.
    So don't worry, I am not upset.

    Quote Originally Posted by phantomotap View Post
    O_o

    Fair enough, but given your predilection, can you blame me for having so inferred?

    Soma
    Nope. Can't blame you.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #47
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,415
    Heck, I called phantom that too when I was new here because I wasn't used to him either but he somehow found a way to move on and he was even gracious enough to help me in this topic.
    O_o

    The phrase "false equivalence" comes to mind.

    I am me; even laserlight (I'm using laserlight because you obviously respect him.) is happy to lose his temper when in conflict with me. Similarly, behavior by grumpy in previous encounters with me has been no different than what you complained of from Nominal Animal.

    [Edit]
    *sigh*

    Whatever, "him"/"her", I really wish English had a modern individual pronoun for neuter sex.
    [/Edit]

    Still, I had no intention of starting something. (I don't even blame you; the result is simply an unfortunate event.) I was only offering fair warning because the "admiration" comment could easily be seen in a similar view to other events.

    Soma
    “Often out of periods of losing come the greatest strivings toward a new winning streak.” -- Fred Rogers
    “Salem Was Wrong!” -- Pedant Necromancer

  3. #48
    Registered User
    Join Date
    Jun 2005
    Posts
    6,646
    Quote Originally Posted by laserlight View Post
    That said, I don't think that it is actually a requirement for a C implementation to have variable length arrays on the stack.
    It's not. In fact, it's quite feasible for a C implementation to manage VLA's on the heap (e.g. hidden calls of malloc() when the VLA is defined, and a free() as the function returns). I haven't checked out how actual compilers do it though.

    Quote Originally Posted by laserlight View Post
    The variable length array feature was only standardised in C99, but C++98 was based on C89/C90. I guess that it was a rather low priority to introduce a language feature that generally is not needed given that std::array and std::vector exist in C++11.
    It's actually interesting seeing how C and C++ have evolved. C++ evolution seems to prefer evolving the standard library, and only changing the core language if it's too hard to do it solely by the standard library. On the other hand, the first line of attack for evolving C seems to be changing or introducing core language features, and implementing additional support to exploit those features in the standard library.

    Quote Originally Posted by MutantJohn View Post
    I remember that topic, though, and I actually miss Nominal. He was really cool until he got mad at grumpy.
    <shrug> It was Nominal who developed a problem with me, not the reverse. I consider he's an absolutist (believes principles, values, and rules are absolute). I'm not.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Sunshine, and read this, this, and this before posting again.

  4. #49
    Registered User
    Join Date
    Oct 2006
    Posts
    2,588
    Quote Originally Posted by phantomotap View Post
    I really wish English had a modern individual pronoun for neuter sex.
    the people who maintain the oxford english dictionary recently (within the last 24 months) declared that they/them is now acceptable to refer to a single person of indeterminate gender.
    Code:
    namespace life
    {
        const bool change = true;
    }

  5. #50
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,415
    It's actually interesting seeing how C and C++ have evolved. C++ evolution seems to prefer evolving the standard library, and only changing the core language if it's too hard to do it solely by the standard library. On the other hand, the first line of attack for evolving C seems to be changing or introducing core language features, and implementing additional support to exploit those features in the standard library.
    O_o

    I see this situation myself, and I feel it was born of so many vendor specific extensions as superior to portable solutions.

    You'd be hard pressed to convince an average C programmer to use "preprocessor tuples" (These were more common than you might think if you didn't work in C before variadic macro extensions were sort of common.) instead of conditionally compiled forms of vendor specific "variadic macros" (C99) because of how super ugly they are to implement and use. If the library only form, "preprocessor tuples", had been standardized instead, everyone needing such a mechanism would have kept using the vendor specific forms. The mechanic needed a language extension to make it palatable.

    Many C++ programmers were/are happy to use "Boost". Sure, "Boost" represented an extension in a way, but for the most part, the core language set was already sufficient to implement these mechanisms with a palatable interface.

    the people who maintain the oxford english dictionary recently (within the last 24 months) declared that they/them is now acceptable to refer to a single person of indeterminate gender.
    I actually try to use the "technical journal" approach adopted by a lot of German translators ([Edit]The approach would be alternating "him" and "her".[/Edit]). I just often forget when in casual conversation.

    Soma
    “Often out of periods of losing come the greatest strivings toward a new winning streak.” -- Fred Rogers
    “Salem Was Wrong!” -- Pedant Necromancer

  6. #51
    Registered User Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    650
    Hodor. HODOR! Hodor?

  7. #52
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,415
    Hodor. HODOR! Hodor?
    O_o

    Well, that may surely be valid, but I haven't worn contacts in years, and besides, where are we going to find a chicken that big?

    Soma
    Elkvis likes this.
    “Often out of periods of losing come the greatest strivings toward a new winning streak.” -- Fred Rogers
    “Salem Was Wrong!” -- Pedant Necromancer

  8. #53
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    BTW, in multi-threaded programs that allocate/deallocate a lot from the heap, having thread-local heaps can help very significantly. For example with Google's tcmalloc.

    But of course, establish the fact that you have a performance problem, and that the performance problem is due to heap allocation first.

    I had a program that spawns many threads and do a bunch operations on std::strings, and switching to tcmalloc gave me a very big speedup.

  9. #54
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,013
    Quote Originally Posted by phantomotap View Post
    O_o

    Well, that may surely be valid, but I haven't worn contacts in years, and besides, where are we going to find a chicken that big?

    Soma
    I find it extremely amazing that you can interpret this. I'm extremely curious: can you share your knowledge on how to read that langauge with us?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #55
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,415
    I find it extremely amazing that you can interpret this. I'm extremely curious: can you share your knowledge on how to read that langauge with us?
    O_o

    I've played every "Pokemon" game released in English as we as the Japanese "Emerald" and "Black".

    After so many years of "Pika Pika Pika" and "SLOOWW", you begin to understand.

    Soma
    “Often out of periods of losing come the greatest strivings toward a new winning streak.” -- Fred Rogers
    “Salem Was Wrong!” -- Pedant Necromancer

  11. #56
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,013
    Oh, I see! I guess I have to go back and play all those Pokémon games and listen to all those Pikachu's Pika, pika, pika then, huh? Then repeat that a few years, and I will understand Hodor language (is that what it's called?). Is that right?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #57
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    I KNEW Hodor was a pokemon! But you all laughed at me!

Page 4 of 4 FirstFirst 1234
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. portable alloca
    By wiglaf in forum C Programming
    Replies: 4
    Last Post: 02-17-2011, 12:34 AM
  2. alloca() function
    By budala in forum C Programming
    Replies: 8
    Last Post: 04-28-2010, 11:09 AM
  3. alloca.h
    By kryptkat in forum C Programming
    Replies: 4
    Last Post: 11-15-2009, 12:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21