fuzziqersoftware / resource_dasm

Classic Mac OS resource fork and application disassembler, with reverse-engineering tools for specific applications
MIT License
113 stars 12 forks source link

compile errors with g++ 13.2.1 20230826 #74

Closed Sembiance closed 1 year ago

Sembiance commented 1 year ago

Running g++ 13.2.1 20230826 and cmake 3.27.4 and the latest resource_dasm 2023-08-31 and phosg 2023-09-21 I get this error:

[20/100] /usr/bin/x86_64-pc-linux-gnu-g++ -Dresource_file_EXPORTS -I/usr/local/include  -O2 -march=native -pipe -std=gnu++20 -fPIC -Wall -Wextra -Werror -Wno-strict-aliasing -O2 -MD -MT CMakeFiles/resource_file.dir/src/ExecutableFormats/PEFile.cc.o -MF CMakeFiles/resource_file.dir/src/ExecutableFormats/PEFile.cc.o.d -o CMakeFiles/resource_file.dir/src/ExecutableFormats/PEFile.cc.o -c /var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/ExecutableFormats/PEFile.cc
FAILED: CMakeFiles/resource_file.dir/src/ExecutableFormats/PEFile.cc.o 
/usr/bin/x86_64-pc-linux-gnu-g++ -Dresource_file_EXPORTS -I/usr/local/include  -O2 -march=native -pipe -std=gnu++20 -fPIC -Wall -Wextra -Werror -Wno-strict-aliasing -O2 -MD -MT CMakeFiles/resource_file.dir/src/ExecutableFormats/PEFile.cc.o -MF CMakeFiles/resource_file.dir/src/ExecutableFormats/PEFile.cc.o.d -o CMakeFiles/resource_file.dir/src/ExecutableFormats/PEFile.cc.o -c /var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/ExecutableFormats/PEFile.cc
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/ExecutableFormats/PEFile.cc: In member function ‘void PEFile::parse(const void*, size_t)’:
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/ExecutableFormats/PEFile.cc:195:17: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
  195 |     const auto& header = this->read_from_rva(
      |                 ^~~~~~
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/ExecutableFormats/PEFile.cc:197:55: note: the temporary was destroyed at the end of the full expression ‘PEFile::read_from_rva(uint32_t, uint32_t) const(((PEFile*)this)->PEFile::header.PEHeader::export_table_rva.little_endian<unsigned int>::<anonymous>.same_endian<unsigned int, unsigned int>::<anonymous>.converted_endian<unsigned int, unsigned int, ident_st<unsigned int, unsigned int>, ident_st<unsigned int, unsigned int> >::operator unsigned int(), ((PEFile*)this)->PEFile::header.PEHeader::export_table_size.little_endian<unsigned int>::<anonymous>.same_endian<unsigned int, unsigned int>::<anonymous>.converted_endian<unsigned int, unsigned int, ident_st<unsigned int, unsigned int>, ident_st<unsigned int, unsigned int> >::operator unsigned int()).StringReader::get<PEExportTableHeader>(1, sizeof (PEExportTableHeader))’
  195 |     const auto& header = this->read_from_rva(
      |                          ~~~~~~~~~~~~~~~~~~~~          
  196 |                                  this->header.export_table_rva, this->header.export_table_size)
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  197 |                              .get<PEExportTableHeader>();
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~^~
cc1plus: all warnings being treated as errors

and

[54/100] /usr/bin/x86_64-pc-linux-gnu-g++  -I/usr/local/include  -O2 -march=native -pipe -std=gnu++20 -Wall -Wextra -Werror -Wno-strict-aliasing -Wno-dangling-reference -O2 -MD -MT CMakeFiles/resource_dasm.dir/src/resource_dasm.cc.o -MF CMakeFiles/resource_dasm.dir/src/resource_dasm.cc.o.d -o CMakeFiles/resource_dasm.dir/src/resource_dasm.cc.o -c /var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/resource_dasm.cc
FAILED: CMakeFiles/resource_dasm.dir/src/resource_dasm.cc.o 
/usr/bin/x86_64-pc-linux-gnu-g++  -I/usr/local/include  -O2 -march=native -pipe -std=gnu++20 -Wall -Wextra -Werror -Wno-strict-aliasing -Wno-dangling-reference -O2 -MD -MT CMakeFiles/resource_dasm.dir/src/resource_dasm.cc.o -MF CMakeFiles/resource_dasm.dir/src/resource_dasm.cc.o.d -o CMakeFiles/resource_dasm.dir/src/resource_dasm.cc.o -c /var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/resource_dasm.cc
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/resource_dasm.cc:533:120: error: ‘std::uint32_t’ has not been declared
  533 |   shared_ptr<const ResourceFile::Resource> load_family_icon(const std::shared_ptr<const ResourceFile::Resource>& icon, std::uint32_t type) {
      |                                                                                                                        ^~~
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/resource_dasm.cc: In member function ‘std::shared_ptr<const ResourceFile::Resource> ResourceExporter::load_family_icon(const std::shared_ptr<const ResourceFile::Resource>&, int)’:
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/resource_dasm.cc:534:20: error: comparison of integer expressions of different signedness: ‘const uint32_t’ {aka ‘const unsigned int’} and ‘int’ [-Werror=sign-compare]
  534 |     if (icon->type == type) {
      |         ~~~~~~~~~~~^~~~~~~
cc1plus: all warnings being treated as errors

Disabling the errors with -Wno-dangling-reference and -Wno-sign-compare allows it to continue but then I get:

[48/100] /usr/bin/x86_64-pc-linux-gnu-g++ -Dresource_file_EXPORTS -I/usr/local/include  -O2 -march=native -pipe -std=gnu++20 -fPIC -Wall -Wextra -Werror -Wno-strict-aliasing -Wno-dangling-reference -O2 -MD -MT CMakeFiles/resource_file.dir/src/TextCodecs.cc.o -MF CMakeFiles/resource_file.dir/src/TextCodecs.cc.o.d -o CMakeFiles/resource_file.dir/src/TextCodecs.cc.o -c /var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/TextCodecs.cc
FAILED: CMakeFiles/resource_file.dir/src/TextCodecs.cc.o 
/usr/bin/x86_64-pc-linux-gnu-g++ -Dresource_file_EXPORTS -I/usr/local/include  -O2 -march=native -pipe -std=gnu++20 -fPIC -Wall -Wextra -Werror -Wno-strict-aliasing -Wno-dangling-reference -O2 -MD -MT CMakeFiles/resource_file.dir/src/TextCodecs.cc.o -MF CMakeFiles/resource_file.dir/src/TextCodecs.cc.o.d -o CMakeFiles/resource_file.dir/src/TextCodecs.cc.o -c /var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/TextCodecs.cc
In file included from /var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/TextCodecs.cc:1:
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/TextCodecs.hh:11:38: error: ‘uint32_t’ was not declared in this scope
   11 | std::string string_for_resource_type(uint32_t type, bool for_filename = false);
      |                                      ^~~~~~~~
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/TextCodecs.hh:4:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
    3 | #include <string>
  +++ |+#include <cstdint>
    4 | 
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/TextCodecs.hh:11:53: error: expected primary-expression before ‘bool’
   11 | std::string string_for_resource_type(uint32_t type, bool for_filename = false);
      |                                                     ^~~~
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/TextCodecs.hh:12:42: error: ‘uint32_t’ was not declared in this scope
   12 | std::string raw_string_for_resource_type(uint32_t type);
      |                                          ^~~~~~~~
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/TextCodecs.hh:12:42: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/TextCodecs.cc:98:65: error: ‘std::string string_for_resource_type(uint32_t, bool)’ redeclared as different kind of entity
   98 | string string_for_resource_type(uint32_t type, bool for_filename) {
      |                                                                 ^
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/TextCodecs.hh:11:13: note: previous declaration ‘std::string string_for_resource_type’
   11 | std::string string_for_resource_type(uint32_t type, bool for_filename = false);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/TextCodecs.cc:113:50: error: ‘std::string raw_string_for_resource_type(uint32_t)’ redeclared as different kind of entity
  113 | string raw_string_for_resource_type(uint32_t type) {
      |                                                  ^
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/TextCodecs.hh:12:13: note: previous declaration ‘std::string raw_string_for_resource_type’
   12 | std::string raw_string_for_resource_type(uint32_t type);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Which I can fix by adding #include <cstdint> to src/TextCodecs.hh

But then I get:

[21/22] /usr/bin/x86_64-pc-linux-gnu-g++  -I/usr/local/include  -O2 -march=native -pipe -std=gnu++20 -Wall -Wextra -Werror -Wno-strict-aliasing -Wno-dangling-reference -Wno-sign-compare -O2 -MD -MT CMakeFiles/hypercard_dasm.dir/src/hypercard_dasm.cc.o -MF CMakeFiles/hypercard_dasm.dir/src/hypercard_dasm.cc.o.d -o CMakeFiles/hypercard_dasm.dir/src/hypercard_dasm.cc.o -c /var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/hypercard_dasm.cc
FAILED: CMakeFiles/hypercard_dasm.dir/src/hypercard_dasm.cc.o 
/usr/bin/x86_64-pc-linux-gnu-g++  -I/usr/local/include  -O2 -march=native -pipe -std=gnu++20 -Wall -Wextra -Werror -Wno-strict-aliasing -Wno-dangling-reference -Wno-sign-compare -O2 -MD -MT CMakeFiles/hypercard_dasm.dir/src/hypercard_dasm.cc.o -MF CMakeFiles/hypercard_dasm.dir/src/hypercard_dasm.cc.o.d -o CMakeFiles/hypercard_dasm.dir/src/hypercard_dasm.cc.o -c /var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/hypercard_dasm.cc
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/hypercard_dasm.cc: In function ‘int main(int, char**)’:
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/hypercard_dasm.cc:1163:29: error: redundant move in initialization [-Werror=redundant-move]
 1163 |       string dir = std::move(*it);
      |                    ~~~~~~~~~^~~~~
/var/tmp/portage/app-arch/resource-dasm-0_p20230831/work/resource_dasm-master/src/hypercard_dasm.cc:1163:29: note: remove ‘std::move’ call
cc1plus: all warnings being treated as errors

If I disable that error with -Wno-redundant-move then everything finishes compiling ok.

fuzziqersoftware commented 1 year ago

Thanks for the report. I don't have a test environment set up where I can easily reproduce these warnings, but I believe they should be fixed by 31486c57. Please let me know if it still doesn't build correctly for you.

Sembiance commented 1 year ago

Thanks. Just tested latest code. Got the following error:

FAILED: CMakeFiles/icon_dearchiver.dir/src/icon_dearchiver.cc.o 
/usr/bin/x86_64-pc-linux-gnu-g++  -I/usr/local/include  -O2 -march=native -pipe -std=gnu++20 -Wall -Wextra -Werror -Wno-strict-aliasing -O2 -MD -MT CMakeFiles/icon_dearchiver.dir/src/icon_dearchiver.cc.o -MF CMakeFiles/icon_dearchiver.dir/src/icon_dearchiver.cc.o.d -o CMakeFiles/icon_dearchiver.dir/src/icon_dearchiver.cc.o -c /var/tmp/portage/app-arch/resource-dasm-0_p20230923/work/resource_dasm-master/src/icon_dearchiver.cc
/var/tmp/portage/app-arch/resource-dasm-0_p20230923/work/resource_dasm-master/src/icon_dearchiver.cc: In function ‘int main(int, const char**)’:
/var/tmp/portage/app-arch/resource-dasm-0_p20230923/work/resource_dasm-master/src/icon_dearchiver.cc:404:15: error: ‘uint32_t’ is not a member of ‘std’; did you mean ‘wint_t’?
  404 |     for (std::uint32_t icon_no = 0; icon_no < icon_count; ++icon_no) {
      |               ^~~~~~~~
      |               wint_t
/var/tmp/portage/app-arch/resource-dasm-0_p20230923/work/resource_dasm-master/src/icon_dearchiver.cc:404:37: error: ‘icon_no’ was not declared in this scope; did you mean ‘icon_count’?
  404 |     for (std::uint32_t icon_no = 0; icon_no < icon_count; ++icon_no) {
      |                                     ^~~~~~~
      |                                     icon_count
/var/tmp/portage/app-arch/resource-dasm-0_p20230923/work/resource_dasm-master/src/icon_dearchiver.cc: At global scope:
/var/tmp/portage/app-arch/resource-dasm-0_p20230923/work/resource_dasm-master/src/icon_dearchiver.cc:181:13: error: ‘void dearchive_icon(DearchiverContext&, uint16_t, uint32_t)’ defined but not used [-Werror=unused-function]
  181 | static void dearchive_icon(DearchiverContext& context, uint16_t version, uint32_t icon_number) {
      |             ^~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
fuzziqersoftware commented 1 year ago

Thanks for your patience. This should be fixed now too.

Sembiance commented 1 year ago

I can confirm it compiles correctly now! Thanks!!!