lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] PATCH: tests build fixes for clang


From: Greg Chicares
Subject: Re: [lmi] PATCH: tests build fixes for clang
Date: Mon, 8 Mar 2021 15:52:07 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0

On 3/7/21 1:10 PM, Vadim Zeitlin wrote:
> 
>  I'd like to submit a series of small fixes to the tests allowing to build
> them with clang, please see https://github.com/let-me-illustrate/lmi/pull/173

These changes are good:
  6b5cbb99d Disable clang tautological constant compare warning in a test
  975ddded0 Disable clang -Wbraced-scalar-init in a test
but I find the clang warnings confusing.

The first may be a matter of terminology. Assigning an integral value V
to an enum variable is
  logically valid for some V, and
  logically invalid for certain other V,
but I'd call it tautologically invalid iff it can be rejected universally
for the category to which V belongs, e.g.:
  oenum_alb_or_anb x;
  x = "fish";
Probably no one else cares about that, but I really did spend time looking
for a deeper, more categorical reason.

The second seems to be misnamed: git-grep easily finds other braced
scalar initializers such as these...

  progress_meter.cpp:    :count_         {0}
  rate_table.cpp:    char index_record[e_index_pos_max] = {0};
  round_to.hpp:    int decimals_                    {0};

...but this patch addresses only instances like this:

     return {n}; // error: narrowing conversion of '128' from 'unsigned int'

...which is a problem not because it's a braced scalar initializer,
but because the value of 'n' would require narrowing. (In this case,
I believe gcc would also issue a warning, if the code were reached.
The difference seems to be that clang flags it even if it's not
reached, which is probably a good feature.)

Searching online gave me the impression that maybe clang really does
intend to complain about all "uniform initialization" (in which case
the other instances above would be flagged, and we'd want to turn this
warning off globally). For example:

https://stackoverflow.com/questions/3462513/gcc-warning-braces-around-scalar-initializer/3462696#3462696
| This is a scalar initializer with braces around it: int foo = {3};
| The warning says that your struct has scalar initializers with braces around 
them

but maybe that author is simply mistaken, and the original poster
had written something like int foo = {{3}} with superfluous '{}'.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]