logo       

[ ghc-Bugs-1153674 ] option -cpp and having C comments gives wrong linenumb: msg#00089

lang.haskell.glasgow.bugs

Subject: [ ghc-Bugs-1153674 ] option -cpp and having C comments gives wrong linenumbers

Bugs item #1153674, was opened at 2005-02-28 10:09
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1153674&group_id=8032

Category: Compiler (Parser)
Group: 6.2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: option -cpp and having C comments gives wrong linenumbers

Initial Comment:
If one tries to compile a .hs file, with the -cpp
option and the file contains
C-style comments (/* comment */), then the linenumbers
GHC reports
are wrong.

Minimal file exhibiting the error:

---
{-
/*
* Copyright (c) 2005 Jesper Louis Andersen
<jlouis@xxxxxxxxxxx>
*
* Permission to use, copy, modify, and distribute this
software for any
* purpose with or without fee is hereby granted,
provided that the above
* copyright notice and this permission notice appear
in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR
DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
*/
-}

c = 3 * "string"

main = putStrLn $ show c
----

; ghc -cpp tmp.hs

tmp.hs:6:
No instance for (Num [Char])
arising from use of `*' at tmp.hs:6
In the definition of `c': c = 3 * "string"

Which is clearly wrong, since ``c'' is not defined on
line 6.

Note I am not sure wether it is in the parser, or it is
rather in compilation
chain where cpp gets invoked one has to look for the
error. I have filed
it as a parser-bug nonetheless.

Fix: cpp(1) seems to output comments in the style
# xx "filename"

where ``xx'' is a number stating the linenumber in the
original file.
Keeping track of this probably fixes the bug.

CPP version: GNU CPP from GCC 3.3.5
Operating System: OpenBSD 3.6-current (GENERIC) #1: Sun
Feb 20 10:23:54 CET 2005

Submitter: Jesper Louis Andersen <jlouis@xxxxxxxxxxx>


----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1153674&group_id=8032


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise