Re: GCC Compilation problem in HP LINUX server

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



gkarthi29 wrote:
Hi

Compiling the following program
#include <stdio.h>
int main()
{
        char **variable=NULL;

        printf("Starting\n");
        fflush(stdout);
        while(*variable)
        {
                printf("Inside while\n");
                fflush(stdout);
                break;
        }
        printf("Ending\n");
        fflush(stdout);
}

Produces the output
Starting
Segmentation fault

Hey

I have to agree with everyone else here, why would you de-referenced a null pointer to something which is un-defined. And then act on something which is un-defined. Maby you could do *variable = something; then do what you want. It isn't anything to do with the compiler.

If i had a compiler that let me run such a program i would be worried.

--Phil

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux