1
General (but related to Code::Blocks) / Re: Welcome Newcomers - PLEASE READ!!!
« Last post by imtiaz_munna on Today at 11:11:10 am » "I am new, I am here"
As usual while waiting for the next release - don't forget to check the nightly builds in the forum.
I very briefly glanced across the commit pointed to by the link.
findings:
class PToken: data-member m_Kind is left uninitialized when PToken is default initialized and when initialized via the ctor with 4 args (while having 5 data-member).
The call to the latter one is also a little errorprone. It might easily be used incorrectly because it has 3 int args. I'd consider member-initializer for the 4 integral data
member and delete the default-ctor.
The cctor of PToken is unecessary and breaks the rule-of-0 without need. It might also copy m_Kind from
an uninitialized data-member. That is undefined behaviour. IMHO the cctor should be removed.
In C++, the "Rule of Zero" is a guideline that suggests avoiding writing custom constructors, destructors, or copy/move assignment operators if the default compiler-generated versions will suffice. The rule states that if a class does not need custom resource management (like dynamic memory allocation), it can rely on the compiler-generated special member functions.
The compound statement after if (IsEOF()) is repeated. It sets 2 data-members of PToken and should be delegated to PToken.
/** Check whether the Tokenizer reaches the end of the buffer (file) */
bool IsEOF() const
{
return m_TokenIndex >= m_BufferLen;
}
I have been looking at this commit (the exact location of the changes was not specified).
PPToken looks to me just a way to pack token information, so I assume the real benefit is using the deque afterwards.
I just suggest changingCodeto thisif (m_PPTokenStream.size() > 0)
Codeif (!m_PPTokenStream.empty())
and removing this partI will read this part of the code later.Codeelse
;// peekToken.Clear();
if (m_PPTokenStream.size() > 0)
if (!m_PPTokenStream.empty())
else
;// peekToken.Clear();