Search code examples
visual-studio-2010visual-studiovisual-c++intellisensevisual-c++-2010

How to report bug in Visual Studio C++ 2010 IDE


I have a program (trimmed way down) that compiles and runs as I think it should, yet in the code window an asterisk (operator*) has a red squiggle under it and the mouse-over caption says, 'Error, no operator * matches these operands.' I guess the squiggly line neglected to tell the compiler. The same thing happens if I change operator* to a function named "dot".

If there are few enough hoops to jump through, I would like to report it to MS. But first, tell me if the compiler and I are wrong, and the squiggle is right.

#include <vector>
#include <iostream>
//#include "fp_vectors.h"
// Header file =================
#include <type_traits>
#include <algorithm>

namespace dj {

    // Dot-product of two real-valued vectors
    template <typename FirstType, typename SecondType> 
    auto operator*(const FirstType &a, const SecondType &b) -> decltype(a[0]*b[0]){
       std::remove_const<decltype(a[0]*b[0])>::type ret = 0.0;
       const int sz = std::min(a.size(),b.size());
       for(int i=0;i<sz;++i) {
           ret += a[i]*b[i];
       }
       return ret;
    }


} // namespace dj

// End header file ================


using namespace std;
typedef vector<float> fvec;
typedef vector<double> dvec;

using namespace dj;

int main()
{
    const size_t sz = 3;
    fvec fv(sz);
    dvec dv(sz);
    for(size_t i=0; i<sz; ++i) {
        fv[i] = -.89f*(i-1.0f);
        dv[i] = 1.6*(i-2.2);
    }
    double ret = dv*fv; // Earns a red squiggly
    cout << ret << endl;
    return 0;
}

Solution

  • Bugs in Visual Studio may be reported on Microsoft Connect.

    However, I took a brief look at your code, and there are no squiggles in Visual Studio 2012. So, if there was a bug here, it looks like it's been fixed.