Skip to content

ToStringHelper wrong logic with enum types #56666

Open
@wooffie

Description

Version

20.18.0

Platform

any

Subsystem

Debug utils (/src/debug_utils-inl.h)

What steps will reproduce the bug?

Use node::toBaseString with enum type.

#include "src/debug_utils-inl.h"

enum SomeEnum : int {
    One, Two, Three
};


int main(){
    std::cout << node::ToBaseString<4>(One) << std::endl;
    std::cout << node::ToBaseString<4>(Two) << std::endl;
}

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

0
1

What do you see instead?

false
true

Additional information

std::forward<T>(value) has enum type which is not isomorphic with boolean type, however it is used as a boolean expression
Can be fixed with std::is_enum_v<T>

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Reporter: Burkov Egor ([email protected]).

Organization: R-Vision ([email protected]).

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions