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


Groups > comp.lang.c > #106679

Re: Array allocated on stack or heap

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Array allocated on stack or heap
Date Tue, 21 Mar 2017 08:17:04 -0700
Organization None to speak of
Lines 49
Message-ID <lnpohabqxb.fsf@kst-u.example.com> (permalink)
References <c2cde792-fb27-45a4-b422-0440077ac0f1@googlegroups.com> <faad0787-be77-4403-a140-0a42613df92b@googlegroups.com> <oahe6s$1b6$1@dont-email.me> <oahf4s$55b$1@dont-email.me> <oahqce$fhe$1@dont-email.me> <oalpv8$v3o$1@dont-email.me> <oalsds$83n$1@dont-email.me> <oaluoh$sbs$1@dont-email.me> <oamco9$h2k$1@dont-email.me> <oao843$nnf$1@dont-email.me> <oaog4l$jl3$1@dont-email.me> <1d52aa30-c145-4131-85cd-1ea3d29b9f74@googlegroups.com> <20170320145406.3450ff4b89d97fb3520ae753@gmail.com> <ec0e7bf9-f19c-4afb-b584-6b4316b12b7b@googlegroups.com> <ln60j4c4ww.fsf@kst-u.example.com> <oaqqje$ok4$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info mx02.eternal-september.org; posting-host="2dce90611c954a97839cf9cb5d391a4e"; logging-data="32674"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18F0WO0fxCaQvGK8MvzgFEL"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock sha1:IVp5VLuF5SgFXZImnvuT8KHvaiA= sha1:AGgVnJDEcbbtL0wm/Cnrn4VEpv0=
Xref csiph.com comp.lang.c:106679

Show key headers only | View raw


David Brown <david.brown@hesbynett.no> writes:
> On 20/03/17 17:02, Keith Thompson wrote:
>> already5chosen@yahoo.com writes:
>> [...]
>>> That's not what I meant. In most places a proper numeric alternative
>>> to 'char' is either int8_t or uint8_t.
>> 
>> Using int8_t or uint8_t makes sense only if you need a type that's
>> *exactly* 8 bits wide, with no padding bits or trap representations,
>> and represented in 2's-complement for int8_t, .  int8_t has a range
>> of exactly -128..+127.  uint8_t has a range of exactly 0..255.  Both
>> types are almost certain to exist in a C99 or later implementation
>> with 8-bit bytes, but they're not guaranteed to exist on all systems.
>> 
>> If you need a narrow numeric type with *at least* a certain range,
>> you can use [u]int_least8_t or [u]int_fast8_t, depending on your
>> requirements.  Or you can use signed char or unsigned char, both
>> of which are guaranteed to be at least 8 bits.  Or, if all you care
>> about is that the range is at least 0..127, you can even use plain
>> char (though for such a purpose either signed char or unsigned char
>> is likely to be more appropriate).
>
> That is all correct.

So you agree with me.

>                       In /most/ places, if you need a very small numeric
> type, then int8_t or uint8_t is the correct type.

So you disagree with me.

[...]

> Yes, there may be occasions when uint_least8_t (or uint_fast8_t) is
> appropriate for portability.  But I think in the huge majority of
> situations where you might want uint_least8_t, then uint8_t would work
> just as well - and it is simpler and clearer, and gives you stronger
> guarantees.

And what if you don't need those stronger guarantees?  How often do you
care whether a signed type uses two's-complement or not?

[...]

-- 
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

Array allocated on stack or heap Prashant Shah <pshah.mumbai@gmail.com> - 2017-03-16 22:58 -0700
  Re: Array allocated on stack or heap Barry Schwarz <schwarzb@dqel.com> - 2017-03-16 23:57 -0700
    Re: Array allocated on stack or heap Mark Storkamp <mstorkamp@yahoo.com> - 2017-03-17 12:44 -0500
      Re: Array allocated on stack or heap Keith Thompson <kst-u@mib.org> - 2017-03-17 11:26 -0700
        Re: Array allocated on stack or heap jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-17 20:38 +0100
          Re: Array allocated on stack or heap Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-17 16:08 -0400
            Re: Array allocated on stack or heap jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-18 00:03 +0100
              Re: Array allocated on stack or heap Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-17 20:54 -0400
  Re: Array allocated on stack or heap John Bode <jfbode1029@gmail.com> - 2017-03-17 12:15 -0700
    Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-17 20:22 +0100
    Re: Array allocated on stack or heap jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-17 20:45 +0100
      Re: Array allocated on stack or heap supercat@casperkitty.com - 2017-03-17 12:59 -0700
      Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-17 21:01 +0100
        Re: Array allocated on stack or heap jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-18 00:12 +0100
          Re: Array allocated on stack or heap jameskuyper@verizon.net - 2017-03-17 16:25 -0700
            Re: Array allocated on stack or heap Keith Thompson <kst-u@mib.org> - 2017-03-17 17:08 -0700
              Re: Array allocated on stack or heap Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-03-17 17:37 -0700
          Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-19 12:30 +0100
            Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-19 12:12 +0000
              Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-19 13:52 +0100
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-19 16:51 +0000
                Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-20 10:44 +0100
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-20 12:01 +0000
                Re: Array allocated on stack or heap already5chosen@yahoo.com - 2017-03-20 06:02 -0700
                Re: Array allocated on stack or heap GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-20 14:54 +0100
                Re: Array allocated on stack or heap already5chosen@yahoo.com - 2017-03-20 07:28 -0700
                Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-20 16:43 +0100
                Re: Array allocated on stack or heap Keith Thompson <kst-u@mib.org> - 2017-03-20 09:02 -0700
                Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-21 10:11 +0100
                Re: Array allocated on stack or heap already5chosen@yahoo.com - 2017-03-21 02:48 -0700
                Re: Array allocated on stack or heap Keith Thompson <kst-u@mib.org> - 2017-03-21 08:19 -0700
                Re: Array allocated on stack or heap Keith Thompson <kst-u@mib.org> - 2017-03-21 08:17 -0700
                Re: Array allocated on stack or heap supercat@casperkitty.com - 2017-03-21 09:06 -0700
                Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-21 17:32 +0100
                Re: Array allocated on stack or heap Les Cargill <lcargill99@comcast.com> - 2017-03-25 15:14 -0500
                Re: Array allocated on stack or heap Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-03-25 16:05 -0700
                Re: Array allocated on stack or heap Les Cargill <lcargill99@comcast.com> - 2017-03-25 23:53 -0500
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-26 12:30 +0100
                Re: Array allocated on stack or heap supercat@casperkitty.com - 2017-03-26 14:09 -0700
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-26 22:17 +0100
                Re: Array allocated on stack or heap Robert Wessel <robertwessel2@yahoo.com> - 2017-03-26 21:52 -0500
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-27 13:06 +0100
                Re: Array allocated on stack or heap supercat@casperkitty.com - 2017-03-27 10:10 -0700
                Re: Array allocated on stack or heap Robert Wessel <robertwessel2@yahoo.com> - 2017-03-27 15:56 -0500
                Re: Array allocated on stack or heap bartc <bc@freeuk.com> - 2017-03-27 22:48 +0100
                Re: Array allocated on stack or heap Robert Wessel <robertwessel2@yahoo.com> - 2017-03-27 19:58 -0500
                Re: Array allocated on stack or heap GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-20 14:56 +0100
                Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-20 15:34 +0100
                Re: Array allocated on stack or heap supercat@casperkitty.com - 2017-03-20 09:28 -0700
                Re: Array allocated on stack or heap bart4858@gmail.com - 2017-03-20 13:05 -0700
                Re: Array allocated on stack or heap supercat@casperkitty.com - 2017-03-20 13:53 -0700
                Re: Array allocated on stack or heap supercat@casperkitty.com - 2017-03-20 14:26 -0700
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-20 22:24 +0000
                Re: Array allocated on stack or heap supercat@casperkitty.com - 2017-03-20 15:44 -0700
                Re: Array allocated on stack or heap already5chosen@yahoo.com - 2017-03-21 02:44 -0700
                Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-21 11:15 +0100
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-21 11:12 +0000
                Re: Array allocated on stack or heap already5chosen@yahoo.com - 2017-03-21 04:23 -0700
                Re: Array allocated on stack or heap scott@slp53.sl.home (Scott Lurndal) - 2017-03-21 13:13 +0000
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-21 13:38 +0000
                Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-21 15:33 +0100
                Re: Array allocated on stack or heap already5chosen@yahoo.com - 2017-03-21 07:38 -0700
                Re: Array allocated on stack or heap already5chosen@yahoo.com - 2017-03-21 07:35 -0700
                Re: Array allocated on stack or heap scott@slp53.sl.home (Scott Lurndal) - 2017-03-21 15:09 +0000
              Re: Array allocated on stack or heap Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-19 13:05 +0000
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-19 13:27 +0000
                Re: Array allocated on stack or heap GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-19 14:26 +0100
                Re: Array allocated on stack or heap Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-19 13:34 +0000
                Re: Array allocated on stack or heap GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-19 14:35 +0100
                Re: Array allocated on stack or heap Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-19 13:36 +0000
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-19 14:00 +0000
                Re: Array allocated on stack or heap Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-19 19:00 +0000
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-19 19:24 +0000
                Re: Array allocated on stack or heap Ian Collins <ian-news@hotmail.com> - 2017-03-20 08:45 +1300
                Re: Array allocated on stack or heap Keith Thompson <kst-u@mib.org> - 2017-03-19 14:32 -0700
                Re: Array allocated on stack or heap Ian Collins <ian-news@hotmail.com> - 2017-03-20 16:16 +1300
                Re: Array allocated on stack or heap Gareth Owen <gwowen@gmail.com> - 2017-03-20 18:58 +0000
                Re: Array allocated on stack or heap raltbos@xs4all.nl (Richard Bos) - 2017-03-24 09:17 +0000
                Re: Array allocated on stack or heap Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-19 20:50 +0000
              Re: Array allocated on stack or heap GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-19 14:10 +0100
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-19 13:38 +0000
                Re: Array allocated on stack or heap GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-19 14:49 +0100
                Re: Array allocated on stack or heap luser droog <luser.droog@gmail.com> - 2017-03-20 07:59 -0700
              Re: Array allocated on stack or heap Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-19 10:57 -0400
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-19 16:14 +0000
                Re: Array allocated on stack or heap Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-19 15:53 -0400
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-19 20:37 +0000
                Re: Array allocated on stack or heap Jean-Marc Bourguet <jm@bourguet.org> - 2017-03-19 23:09 +0100
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-19 22:38 +0000
                Re: Array allocated on stack or heap Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-03-19 16:21 -0700
                Re: Array allocated on stack or heap Ian Collins <ian-news@hotmail.com> - 2017-03-20 16:18 +1300
                Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-20 11:06 +0100
                Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-20 11:00 +0100
              Re: Array allocated on stack or heap supercat@casperkitty.com - 2017-03-19 08:53 -0700
      Re: Array allocated on stack or heap Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-17 16:11 -0400
      Re: Array allocated on stack or heap Keith Thompson <kst-u@mib.org> - 2017-03-17 13:35 -0700
        Re: Array allocated on stack or heap Chad <cdalten@gmail.com> - 2017-03-17 14:00 -0700
          Re: Array allocated on stack or heap jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-17 23:57 +0100
            Re: Array allocated on stack or heap Ian Collins <ian-news@hotmail.com> - 2017-03-18 12:42 +1300
              Re: Array allocated on stack or heap jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-18 00:45 +0100
            Re: Array allocated on stack or heap Chad <cdalten@gmail.com> - 2017-03-18 14:17 -0700
              Re: Array allocated on stack or heap jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-19 19:21 +0100
                Re: Array allocated on stack or heap already5chosen@yahoo.com - 2017-03-19 15:00 -0700
                Re: Array allocated on stack or heap BartC <bc@freeuk.com> - 2017-03-19 22:16 +0000
                Re: Array allocated on stack or heap jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-19 23:57 +0100
                Re: Array allocated on stack or heap Keith Thompson <kst-u@mib.org> - 2017-03-19 16:15 -0700
                Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-20 12:24 +0100
                Re: Array allocated on stack or heap scott@slp53.sl.home (Scott Lurndal) - 2017-03-20 13:24 +0000
            Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-19 13:21 +0100
      Re: Array allocated on stack or heap John Bode <jfbode1029@gmail.com> - 2017-03-17 14:30 -0700
        Re: Array allocated on stack or heap jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-17 23:59 +0100
        Re: Array allocated on stack or heap Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-17 21:02 -0400
        Re: Array allocated on stack or heap David Brown <david.brown@hesbynett.no> - 2017-03-19 13:26 +0100

csiph-web