Skip to content

[C++] Avoid static const variable in the status.h header file #45099

@wgtmac

Description

@wgtmac

Describe the bug, including details regarding any error messages, version, and platform.

We have encountered crash after upgrading to use LLVM 18. After digging into it further, the root cause is that Status::message function below has defined a static const string in the header file which may cause troubles in different translation units.

  const std::string& message() const {
    static const std::string no_message = "";
    return ok() ? no_message : state_->msg;
  }

Component(s)

C++

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions