Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Code Inspection bug

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
jschroedl Posted - Jun 28 2017 : 11:25:44 AM
The dtor of this class is flagged as one which could be replaced with '= default' in the Code Inspection window but that's incorrect. (VA Build 10.9.2223.0 built 2017.06.22)


// Class to log peformance times
class LogTimer
{
public:
	LogTimer(JString msg=JString::empty())
	{ 
		mStart = std::chrono::high_resolution_clock::now();
		mMsg = msg;
	}
	~LogTimer()
	{
		*logStream() << NEWLINE << mMsg << std::chrono::duration<double, std::milli>(std::chrono::high_resolution_clock::now() - mStart).count();
	}
private:
	std::chrono::steady_clock::time_point mStart;
	JString mMsg;
};




John
8   L A T E S T    R E P L I E S    (Newest First)
sean Posted - Sep 26 2017 : 10:59:07 PM
case=109725 is fixed in build 2235
feline Posted - Jul 15 2017 : 07:52:53 AM
That was it, this compiles just fine in VS2015 in a Win32 project. My main test solution is a bit of a mess, for testing different things, but it does compile, just

case=109725

Thank you for the very simple and clear example, and the pointer on how to get this to compile.
jschroedl Posted - Jul 14 2017 : 5:11:03 PM
This compiles in VS 2017, you are probably missing the usual Windows headers. For us, these are included as part of the PCH in stdafx.cpp.

CoInitialize:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms678543 v=vs.85 .aspx
feline Posted - Jul 14 2017 : 1:33:52 PM
I am seeing the same result, but a very simple test class doing the same thing on the constructor is handled correctly by Code Inspection, I am not offered the option to replace the constructor body with = default.

So there is something different about this example. But what really confuses me is that this example, before Code Inspection changes it, does not compile in VS2015. I am getting the error:

error C3861: 'CoInitialize': identifier not found

on the constructor. There is an operator to convert the class to a HRESULT, so I am not sure why this is failing to compile, but it is failing. When I change the constructor m_hr initialisation into something that does compile for me, Code Inspection no longer suggests it can be replaced with = default.

Just to make sure I am not missing something new I have tried VS2017, and again the code fails to compile, with the same error.

Does this sample compile for you?
jschroedl Posted - Jul 14 2017 : 11:26:55 AM
I ran into another case of this today but it also adds a QF suggestion on the ctor (solid underline) which when applied will be invalid code.

class CCoInitialize {
	HRESULT m_hr;

public:
	CCoInitialize() : m_hr(CoInitialize(nullptr)) {};
	~CCoInitialize() { if (SUCCEEDED(m_hr)) CoUninitialize(); }
	operator HRESULT() const { return m_hr; }
};


If I use the Quick Fix for the ctor (dtor has same bad suggestion as this thread showed before), the ctor is now not legal:

	CCoInitialize() : m_hr(CoInitialize(nullptr)) = default;;
feline Posted - Jun 29 2017 : 10:29:13 AM
Thank you for the update, at least this way the quick fix cannot be accidentally triggered. That would have converted this from concerning to quite worrying.
jschroedl Posted - Jun 29 2017 : 09:55:17 AM
quote:
Originally posted by feline

I am seeing the same effect here. Thank you for the clear description.

case=109256

On your system, is Code Inspector offering to do a quick fix for the destructor? I get the same suggestion here, but no quick fix is offered, so I am just wondering if you are seeing the same thing.



No, it does not offer a quick fix for me either.
feline Posted - Jun 28 2017 : 3:52:15 PM
I am seeing the same effect here. Thank you for the clear description.

case=109256

On your system, is Code Inspector offering to do a quick fix for the destructor? I get the same suggestion here, but no quick fix is offered, so I am just wondering if you are seeing the same thing.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000