Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`basic_pbf_builder<TBuffer, T>` submessage constructor does not enforce correct parent tag type.

Open
#155 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp

Research direction

Start at the basic_pbf_builder submessage constructor shown in the issue and inspect the related basic_pbf_writer, pbf_tag_type, and tag-type definitions. Verify how parent and tag types are represented, then add coverage showing that valid construction remains possible and an incorrect parent tag type is rejected at compile time.

Written by the indexing model from the issue text.

Description

This constructor of basic_pbf_builder:

    /**
     * Construct a pbf_builder for a submessage from the pbf_message or
     * pbf_writer of the parent message.
     *
     * @param parent_writer The parent pbf_message or pbf_writer
     * @param tag Tag of the field that will be written
     */
    template <typename P>
    basic_pbf_builder(basic_pbf_writer<TBuffer>& parent_writer, P tag) :
        basic_pbf_writer<TBuffer>{parent_writer, pbf_tag_type(tag)} {
    }

Does not enforce that P is the correct tag type of parent_writer.

Would it be acceptable to submit a PR that replaces or overloads this constructor with:

    /**
     * Construct a pbf_builder for a submessage from the pbf_builder of the parent message.
     *
     * @param parent_writer The parent pbf_builder
     * @param tag Tag of the field that will be written
     */
    template <typename P>
    basic_pbf_builder(basic_pbf_builder<TBuffer, P>& parent_builder, P tag) :
        basic_pbf_writer<TBuffer>{parent_builder, pbf_tag_type(tag)} {
    }

I did not verify that this compiles, but I think it explains the idea.

Dominant language
C++
Stars
381
Forks
83
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mapbox/protozero

All issues in mapbox/protozero

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.