Coder Social home page Coder Social logo

Compilation error in VS2015 about openfst HOT 6 CLOSED

kkm000 avatar kkm000 commented on July 28, 2024
Compilation error in VS2015

from openfst.

Comments (6)

kkm000 avatar kkm000 commented on July 28, 2024

That's nasty. I am using VS2015 for my own main OpenFST project, and not getting the error. What toolset are you using? Have you updated Visual Studio to the latest update version (Help/About)?

The problem is there is a bug in the Microsoft compiler, both in VS 2015 and 2017; look how the same line has changed in the original OpenFST (the orig/1.6 branch here). I added the std::remove_reference although it is not required, only to work around the bug, and this workaround is what giving you the trouble.

from openfst.

kkm000 avatar kkm000 commented on July 28, 2024

For comparison: my Help/About box shows "Version 14.0.25431.01 Update 3", the toolset as selected in the project is "Visual Studio 2015 (v140)", and cl version is 19.00.24215.1. I just checked out fresh project and compiled it. Please check what are yours.

from openfst.

bahtity avatar bahtity commented on July 28, 2024

I faced also the same problem.
Although here what I did just to make the compiler happy, although I am not sure if the code will hit at run time or even either it will work as intended.
in the file string-weight.h, you need to modify line 176 from
typename std::remove_reference<decltype (Weight::rest_)>::const_reverse_iterator iter_;
to
typename std::remove_reference<decltype (Weight::rest_)>::type::const_reverse_iterator iter_;

than in top of class StringWeightIterator , line 140, add the following code, this actually implement the comparison operator the compiler is looking for.

static bool operator == (const std::reverse_iterator<std::_List_const_iterator<std::_List_val<std::_List_simple_types<int>>>> & a, std::_List_const_iterator<std::_List_val<std::_List_simple_types<int>>> &b) 
{
	return a.operator*() == b.operator*();
}

I have visual studio 2015 build 14.0.25431.01 update 3

from openfst.

kkm000 avatar kkm000 commented on July 28, 2024

Fixed, thanks. The issue only occurs when using the template, not when compiling the library itself!

@bahtity, I applied your suggested fix with the missing ::type, thank you, but the second part escapes me. It does not seem right. Note the left of the comparison if an iterator specialized on an iterator, like it's a reverse_iterator on a container of iterators, not values! I suspect a missing iterator dereference somewhere in the code that calls the library. If you have a piece of code that reproduces this error, please open a new issue!

from openfst.

bahtity avatar bahtity commented on July 28, 2024

@kkm000 , you may be right. actually I tried to find the code call this operator but I could not.
I can see your point by trying simplifying the operator code to be like this :

typedef std::_List_simple_types<int> STD_SLT;
typedef std::_List_val<STD_SLT> STD_SLT_V;
typedef std::_List_const_iterator<STD_SLT_V > STD_LCI_SLT_V;
static bool operator == (const	std::reverse_iterator		<STD_LCI_SLT_V> & a, STD_LCI_SLT_V &b)
{
return a.operator*() == b.operator*();
}

if we assumed that the function of the comparison operator is to compares the value the iterator points to the right implantation would be return *a == *b ; instead of return a.operator*() == b.operator*();
i tried the final code and it compile correctly.

typedef std::_List_simple_types<int> STD_SLT;
typedef std::_List_val<STD_SLT> STD_SLT_V;
typedef std::_List_const_iterator<STD_SLT_V > STD_LCI_SLT_V;
static bool operator == (const	std::reverse_iterator		<STD_LCI_SLT_V> & a, STD_LCI_SLT_V &b)
{
	return *a == *b;
}

from openfst.

kkm000 avatar kkm000 commented on July 28, 2024

@bahity: Good, thanks for confirming!

from openfst.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.