Skip to content

Is it correct to cast any char* pointer to another type? #6

@sxstd001

Description

@sxstd001
    template <typename T>
    T read(uint32_t index) const
    {
        if (!p_buffer_ || index + sizeof(T) > limit_)
            return 0;

        return *((T*)&p_buffer_[index]);
    }

i think this is undefined behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions