open-source-parsers / open-source-parsers/jsoncpp

GCC 12.2.0 build warning for uninitialized variable

Open
#1,433 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug build
Dominant language
C++
Stars
8.9k
Forks
2.7k
Avg merge
31m
Merged PRs (30d)
1

Description

Describe the bug
The GCC 12.2.0 compiler warns that a variable may be uninitialized when building JSONCPP, specifically here (v):

  case tokenNull:
    {
    Value v;
    currentValue().swapPayload(v);
    currentValue().setOffsetStart(token.start_ - begin_);
    currentValue().setOffsetLimit(token.end_ - begin_);
    }
    break;

in jsoncpp.cpp

To Reproduce
Just building jsoncpp.cpp in a project.

Expected behavior
No warning.

I even expect that :

Value v(); 

We resolve the issue.

Desktop (please complete the following information):

  • vanilla Arch Linux, GCC 12.2.0

Contributor guide

Open the contributing guide

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.

Research direction

Start with the tokenNull case and the Value v declaration in jsoncpp.cpp. Reproduce the build with GCC 12.2.0 on the reported Arch Linux setup, then verify the warning is eliminated without changing the intended behavior. Done means jsoncpp.cpp builds without the uninitialized-variable warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.