Giter Club home page Giter Club logo

Comments (6)

jorgenhs avatar jorgenhs commented on August 16, 2024

It seems disambiguating the constructors will fix the issue is VS2015:
MutableIfNotReference() = default;
-template<typename... Args>
-explicit MutableIfNotReference(Args&&... args):
-get(std::forward<Args>(args)...)
+template<typename Arg0, typename... Args>
+explicit MutableIfNotReference(Arg0&& arg0, Args&&... args) :
+ get(std::forward<Arg0>(arg0), std::forward<Args>(args)...)
{}

from safe.

LouisCharlesC avatar LouisCharlesC commented on August 16, 2024

Hey, I'm not sure to understand the issue. In the attached file, the line that should construct a value is commented out. But I guess this is the one that has a different behavior under VS2017 and VS2015 ? If it is so, then truly the correct output is "Mutex constructed Value constructed" and VS2015 is wrong.

I don't understand why VS2015 gets it wrong (do you ?) but I guess I see what your fix does. Looking at the code, though, I realize that the variadic constructor covers the default construction and we simply don't need the default constructor statement.

Can you answer these two questions for me, and we'll see how we go along with this:

  1. Do the tests pass on VS2015, when the issue happens ?
  2. Since we don't need the default constructor, can you tell me what happens if you remove it (see attached file) ? Does it solve the problem ?

Thanks for taking the time to share this with me,
Cheers!
L-C

mutableref.h.txt

from safe.

jorgenhs avatar jorgenhs commented on August 16, 2024

Hi @LouisCharlesC , thank you for the rapid response.

I am very sorry for the confusion, indeed the wrong lines are commented out in the code example. The main function should be, as you correctly inferred,

int main()
{
  safe::Safe<FTestValueType, FTestMutexType> X;
  return 0;
}

I have tested simply removing the default constructor, and that seems to have the same effect. This is also a much cleaner fix. :)

- MutableIfNotReference() = default;

  template<typename... Args>
  explicit MutableIfNotReference(Args&&... args) :
    get(std::forward<Args>(args)...)
  {}

I have not had the opportunity to run the tests yet.

from safe.

LouisCharlesC avatar LouisCharlesC commented on August 16, 2024

Stupid C++, if you don't default (or delete) the default constructor, then the type becomes non-trivial. Who knows what else can happen if we don't do exactly the right thing. Solution: do as little as possible. Here's another mutableref.h.txt, could you try it out ?

from safe.

LouisCharlesC avatar LouisCharlesC commented on August 16, 2024

Blimey! This file alone isn't going to work.

Just pull my last commit and check out if it fixes your problem. If so, we're all set!

from safe.

LouisCharlesC avatar LouisCharlesC commented on August 16, 2024

Tests on Windows added.
Also I confirmed that the tests detected this bug on VS2015. Bug was already fixed by previous commit.

from safe.

Related Issues (17)

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.