Mixed line endings(DOS/Unix) in the source file

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

 



Hello,

I recently stumbled upon what for me was surprising behavior of GCC. I
was writing some code on my Linux machine and was using data from a
data dump text file that had DOS line endings. As a commentary to one
of my functions I copied an excerpt from the dump file and
inadvertently added some DOS line endings to my source file. So what I
discovered is that, after that, GCC would output incorrect diagnostic
information in which it would think that an error/warning was present
several lines below its actual location.

The following example(^M denotes DOS line ending) on gcc-4.8.0
compiled with: "gcc test.c -o test.o"

struct a {
        int c;
        void (*f) (void);
};

void foo (void)
{
        /* ^M */
}

struct a A = {
        .c = foo,
        .f = foo,
};

would cause GCC to output:

test.c:14:9: warning: initialization makes integer from pointer
without a cast [enabled by default]
         .f = foo,
         ^

whereas with ^M removed it would say:

test.c:13:9: warning: initialization makes integer from pointer
without a cast [enabled by default]
         .c = foo,
         ^

Is this an expected behavior that I was not aware due to my ignorance?

Thank you,
Andrey Smirnov




[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