A1Liu / a1liu

Personal Repository
https://a1liu.com
MIT License
5 stars 1 forks source link

TString does not compile cleanly #4

Closed huang-a closed 2 years ago

huang-a commented 4 years ago

Compilation with "-pedantic -Wall" produces warnings.

string.cpp: In member function ‘char* CharQueue::enqueue(uint64_t)’:
string.cpp:54:29: error: comparison of integer expressions of different signedness: ‘long int’ and ‘uint64_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
       if (end - section_end >= len) {
           ~~~~~~~~~~~~~~~~~~^~~~~~
string.cpp:63:37: error: comparison of integer expressions of different signedness: ‘long int’ and ‘uint64_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
     if (section_begin - section_end > len) {
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
string.cpp: At global scope:
string.cpp:102:3: error: ISO C++ prohibits anonymous structs [-Werror=pedantic]
   };
   ^
In file included from string.cpp:1:
string.h: In constructor ‘TString::TString()’:
string.h:9:26: error: ‘TString::<unnamed union>::len_value’ will be initialized after [-Werror=reorder]
     uint64_t len_value = 0;
                          ^
string.h:6:28: error:   ‘uint64_t TString::tracker_index’ [-Werror=reorder]
   uint64_t tracker_index = 0;
                            ^
string.cpp:168:1: error:   when initialized here [-Werror=reorder]
 TString::TString() noexcept : start(nullptr), len_value(0), tracker_index(0) {}
 ^~~~~~~
In file included from string.cpp:1:
string.h: In constructor ‘TString::TString(TString&&)’:
string.h:9:26: error: ‘TString::<unnamed union>::len_value’ will be initialized after [-Werror=reorder]
     uint64_t len_value = 0;
                          ^
string.h:6:28: error:   ‘uint64_t TString::tracker_index’ [-Werror=reorder]
   uint64_t tracker_index = 0;
                            ^
string.cpp:194:1: error:   when initialized here [-Werror=reorder]
 TString::TString(TString &&other) noexcept
 ^~~~~~~
In file included from string.cpp:1:
string.h: In copy constructor ‘TString::TString(const TString&)’:
string.h:9:26: error: ‘TString::<unnamed union>::len_value’ will be initialized after [-Werror=reorder]
     uint64_t len_value = 0;
                          ^
string.h:6:28: error:   ‘uint64_t TString::tracker_index’ [-Werror=reorder]
   uint64_t tracker_index = 0;
                            ^
string.cpp:202:1: error:   when initialized here [-Werror=reorder]
 TString::TString(const TString &other) noexcept
 ^~~~~~~
string.cpp: In destructor ‘TString::~TString()’:
string.cpp:216:21: error: comparison of integer expressions of different signedness: ‘uint64_t’ {aka ‘long unsigned int’} and ‘int’ [-Werror=sign-compare]
   if (tracker_index == -1) {
       ~~~~~~~~~~~~~~^~~~~
string.cpp: In member function ‘TString& TString::operator=(const TString&)’:
string.cpp:234:54: error: comparison of integer expressions of different signedness: ‘const uint64_t’ {aka ‘const long unsigned int’} and ‘int’ [-Werror=sign-compare]
   if (other.len_bytes[7] == 0 && other.tracker_index == -1) {
                                  ~~~~~~~~~~~~~~~~~~~~^~~~~
cc1plus: all warnings being treated as errors

Relevant sources: https://github.com/A1Liu/config/blob/master/libs/cplusplus/string_test.h https://github.com/A1Liu/config/blob/master/libs/cplusplus/string_test.cpp

A1Liu commented 2 years ago

I moved TString out because I don't use C++ for much anymore, idk where I put it ://