Skip to content

[BUG] g++ 14 -Wnonnull triggered when compiling with -O2 #1134

@DyXel

Description

@DyXel

Describe the bug
Title. This is a pretty weird one, I am not sure why it only happens when compiling with optimizations.

To Reproduce
Steps to reproduce the behavior:

  1. Compile with: /usr/bin/g++ -std=c++20 -Wall -Wextra -pedantic -Werror -O2 -I./include/ -o cppfront.exe source/cppfront.cpp
  2. Output:
In file included from source/to_cpp1.h:21,
                 from source/cppfront.cpp:18:
source/sema.h: In member function ‘bool cpp2::sema::check(const cpp2::parameter_declaration_node&)’:
source/sema.h:1485:68: error: ‘this’ pointer is null [-Werror=nonnull]
 1485 |             type_name = n.declaration->get_object_type()->to_string();
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from reflect.h2:18,
                 from source/sema.h:21:
source/parse.h:1299:10: note: in a call to non-static member function ‘std::string cpp2::type_id_node::to_string() const’
 1299 |     auto to_string() const
      |          ^~~~~~~~~
cc1plus: all warnings being treated as errors

Additional context
It could be a false-positive, but I haven't analyzed the code yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions