-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure LogDataWorkerThread::interruptRequested_ atomicity. #220
base: master
Are you sure you want to change the base?
Conversation
5a54dd6
to
2cbafe9
Compare
Aren't maxLength_ and indexedSize_ uninitialised? |
Members not listed in the initializer list of a constructor are default-initialized before the body runs and scalars are default-initialized to 0. |
Scalars are initialized to 0 during zero-initialization that is done for members of value-initialized class types that have no constructors. For IndexingData class there is user-provided constructor that does not have maxLength_ and indexedSize_ the initializer list, so default initialization should be performed and these members should end up to have indeterminate value. I think adding them to class initializer list is safer. |
Using the C++11 standard draft n3337 (from 2012-01-16) 12.6 Initialization [class.init] §1
8.5 Initializers [dcl.init] --edit--
§ 6
You seem to be correct, zero-initialization is not performed. --edit end-- §7
§3
|
Thanks @z33ky. Sorry but I still don't see how this apply to our case. maxLength_ and indexedSize_, in this patch, don't have any initializer so §10 doesn't apply here. However: §11
So those two variables will be default-initialized (as opposed to value-initiliazed). Then:
Given those two variables are neither classes or array, surely they are not initialised are they? |
Yes, just after posting I realized this and edited the message.
|
Also I haven't yet mentioned that gin-ahirsch is my account from work. I'll be fixing the PR on Thursday. |
2cbafe9
to
0296b42
Compare
Rebased with index bf33169..5312d44 100644
--- a/src/data/logdataworkerthread.h
+++ b/src/data/logdataworkerthread.h
@@ -36,8 +36,6 @@
class IndexingData
{
public:
- IndexingData() { }
-
// Get the total indexed size
qint64 getSize() const;
@@ -67,8 +65,8 @@ class IndexingData
mutable QMutex dataMutex_;
LinePositionArray linePosition_;
- int maxLength_;
- qint64 indexedSize_;
+ int maxLength_{0};
+ qint64 indexedSize_{0};
EncodingSpeculator::Encoding encoding_{EncodingSpeculator::Encoding::ASCII7};
}; |
Includes a couple of refactorings as separate commits.