folly icon indicating copy to clipboard operation
folly copied to clipboard

Build error with -Werror=return-type

Open hhrsscc opened this issue 1 year ago • 1 comments

Got a build error with -Werror=return-type enabled

folly/folly/settings/Types.cpp: In function ‘std::string_view folly::settings::toString(folly::settings::SetErrorCode)’: folly/folly/settings/Types.cpp:31:1: error: control reaches end of non-void function [-Werror=return-type]

hhrsscc avatar Dec 27 '24 06:12 hhrsscc

std::string_view folly::settings::toString(folly::settings::SetErrorCode error) { switch (error) { case SetErrorCode::kSuccess: return "kSuccess"; case SetErrorCode::kError: return "kError"; // add a program } // Default return (if program doesn't match) return "Unknown Error"; } Function of:  toString(folly::settings::SetErrorCode)  is expected to return a value of type  std::string_view . Therefore, we need to ensure that all execution paths within the function return a value

Anxueim avatar Jan 08 '25 12:01 Anxueim