Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Ö__D_
Beginner
775 Views

error #137: expression must be a modifiable lvalue

Hello,

I have "expression must be a modifiable lvalue" error in compile time. I've tried to compile both icpc and g++ but nothing changed. I'm trying to learn TBB and try to write findMinFloat "finding mininmum element of float array" with parallel_reduce.  My code block is at the below. I have the error while overloading operator() but I do not have while writing a regular function such as foo(). What can be my problem ? 

class findMinFloat
{
    public:
        float *farr;
        int size;
        float minValue;
        int minIndex;
        void operator()(const blocked_range<int> & range) const
        {
            for(int i = range.begin(); i < range.end(); i++)
            {
                if(farr<minValue)
                {
            //        cout<<farr<<endl;
                    minValue    =    farr; // error #137: expression must be a modifiable lvalue
                    minIndex    =    i;/**/    // error #137: expression must be a modifiable lvalue
                }
            }
        }
        void foo()
        {
            for(int i =0; i < 100; i++)
            {
                if(farr<minValue)
                {
                    minValue    =    farr; //NO ERROR
                    minIndex    =    i;/**/   //NO ERROR
                }
            }
        }
    /*    findMinFloat(float *fp)
        {
            farr    =    fp;
            size =    100;
            minValue = 500;
            minIndex = -1;
        }

/*        findMinFloat(findMinFloat &x, split):
            farr(x.farr), minValue(500), minIndex(-1),size(100)
        {};/**/

};/**/

0 Kudos
2 Replies
Alexey_K_Intel3
Employee
775 Views

The operator()() of the body class for parallel_reduce should not be const.

Ö__D_
Beginner
775 Views

Alexey Kukanov (Intel) wrote:

The operator()() of the body class for parallel_reduce should not be const.

Thanks for your answer. It solves my problem.

Reply