From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.comp.gcc.bugs,gmane.emacs.devel Subject: Re: cc-mode adds newlines Date: Thu, 25 Nov 2004 20:35:07 +0000 (GMT) Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: sea.gmane.org 1101422852 32472 80.91.229.6 (25 Nov 2004 22:47:32 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 25 Nov 2004 22:47:32 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: gcc-bugs-return-119728-gcc-bugs=m.gmane.org@gcc.gnu.org Thu Nov 25 23:47:22 2004 Return-path: Original-Received: from sourceware.org ([12.107.209.250]) by deer.gmane.org with smtp (Exim 3.35 #1 (Debian)) id 1CXSOY-0006RH-00 for ; Thu, 25 Nov 2004 23:47:22 +0100 Original-Received: (qmail 26582 invoked by alias); 25 Nov 2004 22:47:21 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Archive: List-Post: List-Help: Original-Sender: gcc-bugs-owner@gcc.gnu.org Original-Received: (qmail 26569 invoked from network); 25 Nov 2004 22:47:16 -0000 Original-Received: from unknown (HELO fencepost.gnu.org) (199.232.76.164) by sourceware.org with SMTP; 25 Nov 2004 22:47:16 -0000 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by fencepost.gnu.org with esmtp (Exim 4.34) id 1CXSMN-0004k0-JM for bug-gcc@gnu.org; Thu, 25 Nov 2004 17:45:07 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1CXSON-0004WE-0C for bug-gcc@gnu.org; Thu, 25 Nov 2004 17:47:11 -0500 Original-Received: from [193.149.49.134] (helo=acm.acm) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CXSOL-0004Vc-Lw; Thu, 25 Nov 2004 17:47:10 -0500 Original-Received: from localhost (root@localhost) by acm.acm (8.8.8/8.8.8) with SMTP id UAA00441; Thu, 25 Nov 2004 20:35:08 GMT X-Sender: root@acm.acm Original-To: Richard Stallman , bug-gcc@gnu.org In-Reply-To: Xref: main.gmane.org gmane.comp.gcc.bugs:83444 gmane.emacs.devel:30363 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:30363 Hi, Richard, Hi, Emacs developers, Hi, gcc maintainers! On Wed, 24 Nov 2004, Richard Stallman wrote: [Subject: gcc's acceptance of string constants which straddle lines.] > Accepting such strings is a violation of the C++ standard, I think. I'll > need to complain about this to GCC. Possibly, I'll not be the first. >We do not "violate" the C++ standard, we diverge from it. We do not >regard standards as authorities. We make our own decisions. OK. That's fine by me, but ..... The situation which bit me was this: In our embedded system, commands get sent from device to device as strings of ASCII, a fairly normal thing. One particular command string was, in essence, coded thus: const char *command = "aaaa bbbb" ; which normally compiles to "aaaa bbbb". The receiving device ignores the white space. However, due to a mixup with proprietory version control systems and editors, this source file somehow got to the build process with "proprietory" line terminators. gcc compiled the file without complaint (on QNX, a proprietory Posix system), but the command string ended up as "aaaa bbbb". To the receiving device, the meant something like "do not process the rest of this command". To track the resulting bug down took about 40 hours of work, all told. This is, I think, the reason why the C and C++ standards don't allow strings to straddle lines: the meaning of a source file can change with the EOL convention. Now, I like proprietory file formats almost as little as you do, and over the decades, in projects like ours, they must have wasted untold billions of dollars, pounds, Marks, Yen, Francs, ...., not to mention trillions of Lira and Pesetas ;-). It would have been nice to have got at least a warning message here. Of course, the Right Thing is for me to put the appropriate option (perhaps -traditional-cpp?) into the build scripts. The solution I actually adopted was to purge all such strings from the source files (all ~2200 of them - it's a very slackly written program :-( It took me ~half a day to write a regular expression to find them). However, those 40 hours of work are lost forever :-(. But I _do_ understand the need for having strings straddling lines, too. It's would be a pain in the donkey to have to end every line of, for example, the doc string in a DEFUN macro with ....\n", and things like that. And I _do_ understand that it's desirable, sometimes, to compile those strings with the target OS's EOL convention. >Complain if you wish, but I will not agree to the absurd limitation of >string constants to a single line. By "complain", I meant simply to draw my experiences to the attention of the gcc maintainers, and ask them to consider, perhaps, whether the gcc options (or their defaults) might be modified in some way so as to help other projects avoid falling into the same trap as mine did, whilst at the same time not inconveniencing those who positively need such strings. I was not proposing throwing some sort of temper fit. I think you know me better than that by now. ;-) So, gcc people: is there a way? Thanks in advance! -- Alan Mackenzie (Munich, Germany)