Bug 447833 - cpp adds extraneous blank lines at beginning of output
Summary: cpp adds extraneous blank lines at beginning of output
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 8
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-05-22 01:33 UTC by JW
Modified: 2008-05-29 14:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-05-29 14:38:57 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description JW 2008-05-22 01:33:32 UTC
Description of problem:
cpp adds extraneous blank lines at beginning of output

Version-Release number of selected component (if applicable):
gcc-4.1.2-33

How reproducible:
Always

Steps to Reproduce:
1. echo "/**/" >test
2. cpp -P -C test
  
Actual results:
Two extra empty lines inserted at beginning of output.

Expected results:
Output should be exactly the same as input because of -C (and -P) option.

Additional info:
Why is this a problem?  Because if using cpp to preprocess other languages (eg
for java code which needs C/C++ include definitions) then line numbers are not
preserved.

Comment 1 Jakub Jelinek 2008-05-29 10:57:03 UTC
cpp never makes any whitespace guarantees.

Comment 2 JW 2008-05-29 11:02:45 UTC
Yes, it does.

> When GCC is given the `-traditional-cpp' option, it attempts to emulate a
> traditional preprocessor.


Comment 3 Jakub Jelinek 2008-05-29 14:18:58 UTC
And how is that relevant to this?  You are not using -traditional-cpp, nor this
describes how traditional preprocessor should behave.

Comment 4 JW 2008-05-29 14:30:08 UTC
Yes, I was also using -traditional-cpp but I inadvertently forgot to say so.
There could be a bug in my bug entry mechanism.  But that mechanism never makes
any guarantees about accuracy.

Also, cpp -P -C also adds the two extra lines. So the bug manifests itself in a
variety of ways.

Find the cause of this bug and you might find something bigger. Are you sure you
wont?


Comment 5 Jakub Jelinek 2008-05-29 14:38:57 UTC
As I said, cpp never does try to preserve the whitespace, never did.
When you use -P you simply mean you don't care about mapping lines back to the
original source.
The two lines in the beginning in particular come from the builtin defines (try
e.g. preprocessing with -dM to see what is there).  Please stop reopening this.


Note You need to log in before you can comment on or make changes to this bug.