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


Groups > comp.lang.c > #61691

Re: Implementing static_assert

Path csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Implementing static_assert
Date Thu, 07 May 2015 09:11:12 -0700
Organization None to speak of
Lines 23
Message-ID <87d22cjrkv.fsf@kst-u.example.com> (permalink)
References <midqsq$81d$1@dont-email.me> <mif6mb$ffc$1@dont-email.me> <MPG.2fb4e3efad69db5721@news.eternal-september.org> <miflb1$36l$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx02.eternal-september.org; posting-host="9be37d943435275679235b07c7947eef"; logging-data="17917"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/PKUvYUwltuNy2YTkbk8Fc"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
Cancel-Lock sha1:cA9w06VxgdkxSgtD9G4AR03robA= sha1:C9t0igjaEFhX/t2zhTqgQVmgGME=
Xref csiph.com comp.lang.c:61691

Show key headers only | View raw


David Brown <david.brown@hesbynett.no> writes:
> On 07/05/15 12:53, Philip Lantz wrote:
>> David Brown wrote:
>>> Conversely, I would consider turning an "old-fashioned" assert into a
>>> static assertion if the expression is compile-time constant.
>> 
>> No, you can't do that--even if the expression in an assert is a compile-
>> time constant, the program can't abort unless/until it is executed. 
[...]

> That's why I said I would /consider/ doing this - I realise there are
> cases where you might want to avoid a compile-time error here.

Yes -- and those cases are *all uses of assert()*.

> But certainly it is not something one could change easily without
> breaking existing code.

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

Implementing static_assert jacobnavia <jacob@jacob.remcomp.fr> - 2015-05-06 21:44 +0200
  Re: Implementing static_assert Keith Thompson <kst-u@mib.org> - 2015-05-06 13:28 -0700
    Re: Implementing static_assert jacobnavia <jacob@jacob.remcomp.fr> - 2015-05-06 22:55 +0200
      Re: Implementing static_assert Keith Thompson <kst-u@mib.org> - 2015-05-06 14:30 -0700
        Re: Implementing static_assert Martin Shobe <martin.shobe@yahoo.com> - 2015-05-06 18:07 -0500
          Re: Implementing static_assert Keith Thompson <kst-u@mib.org> - 2015-05-06 17:34 -0700
          Re: Implementing static_assert David Brown <david.brown@hesbynett.no> - 2015-05-07 09:44 +0200
      Re: Implementing static_assert Tim Rentsch <txr@alumni.caltech.edu> - 2015-05-07 12:37 -0700
  Re: Implementing static_assert David Brown <david.brown@hesbynett.no> - 2015-05-07 10:11 +0200
    Re: Implementing static_assert Ian Collins <ian-news@hotmail.com> - 2015-05-07 22:13 +1200
      Re: Implementing static_assert jacobnavia <jacob@jacob.remcomp.fr> - 2015-05-07 12:24 +0200
        Re: Implementing static_assert Ian Collins <ian-news@hotmail.com> - 2015-05-07 22:33 +1200
          Re: Implementing static_assert David Brown <david.brown@hesbynett.no> - 2015-05-07 14:30 +0200
    Re: Implementing static_assert Philip Lantz <prl@canterey.us> - 2015-05-07 03:53 -0700
      Re: Implementing static_assert David Brown <david.brown@hesbynett.no> - 2015-05-07 14:21 +0200
        Re: Implementing static_assert Keith Thompson <kst-u@mib.org> - 2015-05-07 09:11 -0700
          Re: Implementing static_assert James Kuyper <jameskuyper@verizon.net> - 2015-05-07 12:30 -0400
            Re: Implementing static_assert James Kuyper <jameskuyper@verizon.net> - 2015-05-07 12:55 -0400
    Re: Implementing static_assert Keith Thompson <kst-u@mib.org> - 2015-05-07 09:06 -0700
  Re: Implementing static_assert jacobnavia <jacob@jacob.remcomp.fr> - 2015-05-07 19:43 +0200
    Re: Implementing static_assert Tim Rentsch <txr@alumni.caltech.edu> - 2015-05-07 16:10 -0700

csiph-web