Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #61155

Re: Syntax error?

From Bartc <bc@freeuk.com>
Newsgroups comp.lang.c
Subject Re: Syntax error?
Date 2015-04-26 19:55 +0100
Organization A noiseless patient Spider
Message-ID <mhjca2$amb$1@dont-email.me> (permalink)
References <mhg0mq$f25$1@dont-email.me> <kfnmw1vouoe.fsf@x-alumni2.alumni.caltech.edu>

Show all headers | View raw


On 26/04/2015 15:01, Tim Rentsch wrote:
> Bartc <bc@freeuk.com> writes:
>
>> How fast can you spot the problem in this code:
>>
>> *(int (*))((char*)sptr+8)=(*(int (*))((char*)x+8)/*(int (*))((char*)y+8));
>>
>> It was somewhat harder for me as the
>> compiler says nothing about it until the
>> next function dozens of lines later and
>> then it picks on something totally
>> unrelated.
>
> This code is program-generated, yes?  You might
> want to run the output through a formatter before
> compiling it - that would make problems like this
> much easier to diagnose.
>

The code generator already has to function as a formatter of sorts, and 
I make sure it's indented correctly and braces are used consistently.

However the viewer I use doesn't highlight /*...*/ comments unless they 
start a line, otherwise it might have been more obvious. (Although I'm 
already inured to C code being highlighted as a comment half-way across 
a line because it thinks C's ! or != operator "!" starts a comment.)

But what I was more astonished at was this glaring hole in the language 
where "/*" starts a comment even though it can also form part of a legal 
expression. I was aware of a similar problem with // comments but not 
/*...*/ ones. It's obvious now of course.

(Maybe I should added a few more parentheses...)

-- 
Bartc

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Syntax error? Bartc <bc@freeuk.com> - 2015-04-25 13:19 +0100
  Re: Syntax error? Richard Damon <Richard@Damon-Family.org> - 2015-04-25 11:07 -0400
  Re: Syntax error? jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-25 18:03 +0200
    Re: Syntax error? Bartc <bc@freeuk.com> - 2015-04-25 17:26 +0100
      Re: Syntax error? jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-25 19:28 +0200
  Re: Syntax error? Johannes Bauer <dfnsonfsduifb@gmx.de> - 2015-04-26 11:19 +0200
    Re: Syntax error? Bartc <bc@freeuk.com> - 2015-04-26 11:17 +0100
      Re: Syntax error? Bartc <bc@freeuk.com> - 2015-04-26 11:36 +0100
        Re: Syntax error? Ben Bacarisse <ben.lists@bsb.me.uk> - 2015-04-26 13:40 +0100
          Re: Syntax error? Bartc <bc@freeuk.com> - 2015-04-26 19:27 +0100
            Re: Syntax error? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-26 12:38 -0700
              Re: Syntax error? Bartc <bc@freeuk.com> - 2015-04-26 22:26 +0100
            Re: Syntax error? Keith Thompson <kst-u@mib.org> - 2015-04-26 12:41 -0700
            Re: Syntax error? Ben Bacarisse <ben.lists@bsb.me.uk> - 2015-04-27 01:53 +0100
      Re: Syntax error? Bartc <bc@freeuk.com> - 2015-04-26 13:24 +0100
  Re: Syntax error? Tim Rentsch <txr@alumni.caltech.edu> - 2015-04-26 07:01 -0700
    Re: Syntax error? Bartc <bc@freeuk.com> - 2015-04-26 19:55 +0100
      Re: Syntax error? Robert Wessel <robertwessel2@yahoo.com> - 2015-04-27 02:39 -0500
      Re: Syntax error? Tim Rentsch <txr@alumni.caltech.edu> - 2015-04-28 08:34 -0700

csiph-web