[Top][All Lists]

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

[Octave-bug-tracker] [bug #53650] build: clang-6.0 compiler warnings

From: Rik
Subject: [Octave-bug-tracker] [bug #53650] build: clang-6.0 compiler warnings
Date: Sun, 15 Apr 2018 10:54:27 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0

Follow-up Comment #7, bug #53650 (project octave):

I'm pretty sure at this point that the clang warning is not to be trusted. 
How would zero make it in to the lambda function other than by capture or
parameter?  According to the documentation for std::count_if
(http://www.cplusplus.com/reference/algorithm/count_if/) the predicate
function test has to be a unary function.  That means zero can't be passed in
via a parameter.  On the other hand, If I remove the capture for zero then gcc
throws an error

./liboctave/array/MDiagArray2.h: In lambda function:
./liboctave/array/MDiagArray2.h:97:56: error: ‘zero’ is not captured
                           [] (T elem) { return elem != zero; });
./liboctave/array/MDiagArray2.h:97:28: note: the lambda has no
                           [] (T elem) { return elem != zero; });
./liboctave/array/MDiagArray2.h:94:13: note: ‘const T zero’ declared here
     const T zero = T ();

I suppose we could drop this entirely and go back to a for loop

  octave_idx_type nnz (void) const
    const T *d = this->data ();

    const octave_idx_type nel = this->length ();

    const T zero = T ();

    octave_idx_type nnz = 0;
    for (octave_idx_type i = 0; i < nel; i++) 
        if (*d != zero)

   return nnz;


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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