Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c++
Subject: Re: A question about if constexpr
Date: Thu, 28 Nov 2019 13:52:35 -0800
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <86d0dbact8.fsf@linuxsc.com>
References: <9d930f21-6639-49a3-8ef2-5de724f18255@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="dce185ee50ea005ee4a34884a21fb89a"; logging-data="29801"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19hh/Lzrw5aWKkLz1GfNMy45nAux/tPNBY="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:bmWecN9zQBiCStYBy73uyKciibI= sha1:8DLTIJW6HJMYCQ7VfE+ViCO9/y4=
Xref: csiph.com comp.lang.c++:70096
Daniel writes:
> Consider
>
> #include
> #include
>
> int main()
> {
> constexpr int n = 1;
> constexpr int m = 10;
> std::string s = "abcd";
>
> if (n < m || s.empty())
> {
> std::cout << "ok\n";
> }
> }
>
> Is it reasonable that vs2019 produces a warning
>
> warning C4127: conditional expression is constant
> consider using 'if constexpr' statement instead
Let me rephrase your question as a multiple choice:
"A compiler operating under default option settings
produces this warning message for the above program.
Would you be more likely to describe this choice as
(A) reasonable, or
(B) monumentally stupid?"
Asked like this, my answer would be (B).
There are, I am sure, a large number of related questions,
for which I expect I would give various answers depending
on the particular question.