This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Another weird CPP result


Jason R Thorpe wrote:-

>  > FAIL: cmdlne-dM-M.c: #define line not printed
> 
> I'm not really sure what's supposed to happen with this test case.  If
> I run the test-case as dejagnu does, the resulting file contains:
> 
> ss20-1:thorpej 19$ cat cmdlne-dM-M.i                                           
> cmdlne-dM-M.o:  \
>  /amd/yeah-baby/u1/hack/gnu-toolchain/gcc/gcc/gcc/testsuite/gcc.dg/cpp/cmdlne-dM-M.c
> ss20-1:thorpej 20$ 
> 
> However, if I remove the "-o cmdlne-dM-M.i" from the command, and let it
> go to stdout, I see:
> 
> #define __CHAR_BIT__ 8
[...]
> #define __VERSION__ "3.2 20020714 (experimental)"
> cmdlne-dM-M.o:  \
>  /amd/yeah-baby/u1/hack/gnu-toolchain/gcc/gcc/gcc/testsuite/gcc.dg/cpp/cmdlne-dM-M.c
> ss20-1:thorpej 21$ 
> 
> I'm not really sure what's going on, here.  What is GCC doing differently
> when it gets the -o?

The test is a bit baroque.  If dependencies and normal output go to the
same FILE *, we end up closing it twice (the first happens, I think,
before the other output has occurred, so it goes nowhere).

There is an explicit check for stdout in cpplib to avoid this for that
one case (cppinit.c:1075).  The problem is to avoid it in general.
Zack mentioned reworking the code so that cpplib didn't handle opening
and closing FILE *s, instead the client would just pass them and handle
the open / close itself.  It hasn't been done yet, though.

I'm still not clear how this solves the problem in general, since
different paths can refer to the same file.  Under UNIX we can check
dev/inode pairs, but I'm not aware of a proper portable solution.

Neil.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]