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


Groups > comp.lang.c > #112208

Re: isspace() executes without ctype header?

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: isspace() executes without ctype header?
Date 2017-06-14 10:21 -0700
Organization None to speak of
Message-ID <lnvanycwne.fsf@kst-u.example.com> (permalink)
References <ohq29k$892$1@dont-email.me> <B380B.92754$gM7.35332@fx44.am4> <ln8tkuede3.fsf@kst-u.example.com> <FMd0B.48820$l11.30373@fx01.am4>

Show all headers | View raw


bartc <bc@freeuk.com> writes:
> On 14/06/2017 17:35, Keith Thompson wrote:
>> bartc <bc@freeuk.com> writes:
>
>>> code is only for x64 etc), but can give a second opinion on code that
>>> apparently passes error-free with other compilers.
>> 
>> Why would a second opinion be needed?
>
> A second opinion from a compiler, that might give you a hint that 
> another compiler might be too forgiving.
>
>> The standard is clear.
>
> On this point, what the standard says isn't helpful.

I disagree.

> What IS helpful is that when a function call is used, the correct 
> declaration for that declaration is visible.

Yes, programmers should ensure that a correct declaration is visible for
each called function.  (C90 compilers are not necessarily helpful in
doing that.)

> While a compiler can't know for certain the declared signature is 
> correct, other than checking the number and compatibility of arguments, 
> at least it should complain if it's missing completely!

I agree -- and conforming C99 and C11 compilers do so.  C90 compilers
are not required to complain.

> Some compilers will say nothing (tcc and DMC), some will just give a 
> warning (that can be mixed up with harmless ones so can be missed), some 
> will only generate an error when the right incantation of options.
>
> A missing declaration should simply be an ERROR, full stop. If legacy 
> code has missing declarations, then it needs to be fixed.

I agree.

>> Of course the solution for programmers is easy.  If you call isspace(),
>> add "#include <ctype.h>", even if your code is only intended to be
>> compiled as C90.
>
> C90 was at fault too. Why allow something so sloppy? And potentially 
> dangerous.

Yes, the C90's implicit int rule was a problem.  That problem was solved
18 years ago by removing the implicit int rule in C99.  Not all
compilers conform to C99 or C11 requirements.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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


Thread

isspace() executes without ctype header? DFS <nospam@dfs.com> - 2017-06-13 21:13 -0400
  Re: isspace() executes without ctype header? Ian Collins <ian-news@hotmail.com> - 2017-06-14 13:20 +1200
    Re: isspace() executes without ctype header? DFS <nospam@dfs.com> - 2017-06-13 21:33 -0400
      Re: isspace() executes without ctype header? Ian Collins <ian-news@hotmail.com> - 2017-06-14 13:35 +1200
        Re: isspace() executes without ctype header? DFS <nospam@dfs.com> - 2017-06-13 22:31 -0400
          Re: isspace() executes without ctype header? Ian Collins <ian-news@hotmail.com> - 2017-06-14 14:40 +1200
  Re: isspace() executes without ctype header? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2017-06-13 21:49 -0400
  Re: isspace() executes without ctype header? Tim Rentsch <txr@alumni.caltech.edu> - 2017-06-13 19:20 -0700
    Re: isspace() executes without ctype header? DFS <nospam@dfs.com> - 2017-06-13 23:04 -0400
      Re: isspace() executes without ctype header? asetofsymbols@gmail.com - 2017-06-13 23:07 -0700
      Re: isspace() executes without ctype header? Tim Rentsch <txr@alumni.caltech.edu> - 2017-06-14 08:26 -0700
        Re: isspace() executes without ctype header? bartc <bc@freeuk.com> - 2017-06-14 17:29 +0100
          Re: isspace() executes without ctype header? Keith Thompson <kst-u@mib.org> - 2017-06-14 09:46 -0700
            Re: isspace() executes without ctype header? bartc <bc@freeuk.com> - 2017-06-14 17:54 +0100
              Re: isspace() executes without ctype header? Keith Thompson <kst-u@mib.org> - 2017-06-14 10:17 -0700
              Re: isspace() executes without ctype header? supercat@casperkitty.com - 2017-06-14 10:48 -0700
                Re: isspace() executes without ctype header? Keith Thompson <kst-u@mib.org> - 2017-06-14 12:03 -0700
                Re: isspace() executes without ctype header? supercat@casperkitty.com - 2017-06-14 12:48 -0700
                Re: isspace() executes without ctype header? Keith Thompson <kst-u@mib.org> - 2017-06-14 13:06 -0700
            Re: isspace() executes without ctype header? Tim Rentsch <txr@alumni.caltech.edu> - 2017-06-16 23:14 -0700
  Re: isspace() executes without ctype header? bartc <bc@freeuk.com> - 2017-06-14 11:18 +0100
    Re: isspace() executes without ctype header? Keith Thompson <kst-u@mib.org> - 2017-06-14 09:35 -0700
      Re: isspace() executes without ctype header? bartc <bc@freeuk.com> - 2017-06-14 17:47 +0100
        Re: isspace() executes without ctype header? supercat@casperkitty.com - 2017-06-14 10:19 -0700
          Re: isspace() executes without ctype header? Keith Thompson <kst-u@mib.org> - 2017-06-14 10:29 -0700
        Re: isspace() executes without ctype header? Keith Thompson <kst-u@mib.org> - 2017-06-14 10:21 -0700
          Re: isspace() executes without ctype header? bartc <bc@freeuk.com> - 2017-06-14 19:12 +0100
            Re: isspace() executes without ctype header? Keith Thompson <kst-u@mib.org> - 2017-06-14 12:12 -0700
            Re: isspace() executes without ctype header? joel.rees@gmail.com - 2017-06-16 17:56 -0700
              Re: isspace() executes without ctype header? supercat@casperkitty.com - 2017-06-17 10:20 -0700
                Re: isspace() executes without ctype header? Robert Wessel <robertwessel2@yahoo.com> - 2017-06-18 00:25 -0500
                Re: isspace() executes without ctype header? supercat@casperkitty.com - 2017-06-19 09:01 -0700
                Re: isspace() executes without ctype header? Robert Wessel <robertwessel2@yahoo.com> - 2017-06-19 21:59 -0500

csiph-web