8000 [C++] Read of possibly uninitialised variable · Issue #562 · aeron-io/aeron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[C++] Read of possibly uninitialised variable #562
Closed
@mattgodbolt

Description

@mattgodbolt

Picked up by clang --analyze:

In file included from 
include/concurrent/AtomicBuffer.h:25:
include/util/StringUtil.h:146:13: warning: The right operand of '==' is a garbage value
    if ('y' == response || 'Y' == response)
            ^  ~~~~~~~~

And it's not wrong:

inline bool continuationBarrier(const std::string& label)
{
    bool result = false;
    char response;
    std::cout << std::endl << label << " (y/n): ";
    std::cin >> response;  // <--------- if the cin fails here (e.g. stdin has been closed), response will be left uninitialised

    if ('y' == response || 'Y' == response)
    {
        result = true;
    }

    return result;
}

Metadata

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

      0