Thread: strange compiler

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    141
    Quote Originally Posted by Salem View Post
    VLA's are essentially useless candy IMO.

    The biggest problem is what happens if your VLA no longer fits on the stack (assuming that is where VLAs get created on a given machine). Even the best scenario results in the program being killed by the OS. On an embedded system, it probably just trashes someone else's memory. Nor is there a way of finding out in advance whether it will succeed or not, just close your eyes, pray and take a jump.

    Of course, a lot of naive programmers are going to take unchecked user input, and create their VLA directly from that. Most of them won't even bother to check for negative numbers, nevermind huge positive numbers.

    At least with malloc, there is a clearly defined way of being told there is no more room, and from there you can take appropriate action.
    Yes all true, but it has a place. If you need scratch memory allocated dynamically it can be quite convenient. For example if I'm doing a bunch of matrix operations, or even a bunch of rotations using quaternions for graphics applications, I'd like to be able to allocate some temp memory of small but possibly unknown size; use it for my calculations and then discard it.

    I suppose also, if you want to get a little more sophisticated you can try to increase your stack size. I know how to do that in assembly language, but I'm not sure about the various C compilers. Microsoft no doubt has some pragmas that support it and maybe gcc does to. Unfortunately MS has decided in recent versions of their compilers that inline assembly is simply not necessary any more.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    If you're not fully compliant, then you're not compliant. Don't they teach people anything in school any more? Didn't you ever learn that "in a true or false question, if any of it is false, then the whole thing is false"? Thus, is it compliant? No.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    Quote Originally Posted by quzah View Post
    If you're not fully compliant, then you're not compliant. Don't they teach people anything in school any more? Didn't you ever learn that "in a true or false question, if any of it is false, then the whole thing is false"? Thus, is it compliant? No.
    Quzah.
    Compliance in so much as it pertains to the more notorious of the C99 standards, such as those that make it possible for the OP's code to compile. In this context, the qualifier "fully" makes it clearer as to whether it complies with every C99 standard, as it is not uncommon to refer to a compiler as C99 even though it supports only the majority of these standards. It's a shame the english language isn't completely boolean quantifiable huh?

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by @nthony View Post
    It's a shame the english language isn't completely boolean quantifiable huh?
    Maybe.


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,667
    > Quincy 99
    > Code::Blocks
    > Dev-C++
    You do know the difference between an IDE and a compiler right?

    Because all of those things are IDEs which basically come 'out of the box' with the MinGW port of gcc as the actual compiler.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange results using dnsapi and windns
    By Niara in forum Networking/Device Communication
    Replies: 3
    Last Post: 08-13-2005, 10:21 AM
  2. Have you ever written a compiler?
    By ammar in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 12-27-2004, 07:10 AM
  3. Dev C++ Compiler, Indentation?
    By Zeusbwr in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2004, 06:13 AM
  4. lcc win32 compiler download problems
    By GanglyLamb in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-01-2004, 07:39 PM
  5. simple error or strange compiler?
    By threahdead in forum C Programming
    Replies: 6
    Last Post: 01-20-2003, 03:00 PM