new gcc no longer works properly(gcc4.2)

Discussion in 'Mac Programming' started by ClausW, Mar 24, 2012.

  1. ClausW macrumors newbie

    Mar 24, 2012
    Dear forummers,
    I have recently installed Lion on my macbook and then I installed the new Xcode, but upon discovering that the terminal gcc was no longer working I also installed that through Xcode(sth like command line tools).

    Anyway, gcc is installed, but it works very strangely. The function rand() began no longer working properly(always giving me approx. same numbers), and even a simple for loop stopped working, getting stuck in the last term of it and not being able to escape from it.

    I might post code here, but it won't be of use: My program was working perfectly till I got the new gcc. I can't believe I am the only one having difficulties with the new gcc.

    Upon entering "gcc -v" it returns: gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
  2. gnasher729 macrumors P6


    Nov 25, 2005
    Two possibilities: 1. Your program contained some serious bugs, but worked by pure chance with the older compiler version. 2. Your program was correct, but the newer compiler version is broken. So what is more likely? Without code, we won't know. If an experienced developer thinks they ran into a compiler bug, there is a 99% chance they are wrong. For inexperienced developers the number is higher.

    I'd try a different compiler, like LLVM, and see what happens. If you have XCode 4.3.1, you could try LLVM and the new standard library implementation.
  3. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    rand() must be seeded. If you don't seed it, or seed it with the same or similar values, it will produce the same or similar outputs.

    This is one reason the man page's brief description for rand is this:
    rand, srand, sranddev, rand_r -- bad random number generator
    (Emphasis added)

    Frankly, without knowing how you're seeding it, and without knowing how you're using it, there's no way to diagnose the problem. The same thing goes for your "simple for loop". We don't know what you coded, and anyon'e idea of a simple for loop can mean anything in the actual code.

    In short, without code, it's all just guessing.

Share This Page