Skip to content

decode(state, codep, byte) generates warnings. #3837

Closed
@SimonPeacock

Description

@SimonPeacock

Description

Quite minor.. BUT

json.hpp, line 18822 ..
1/ the third parameter is named byte, 'byte' is also a 'type' and may lead to confusion.
It is also a public variable used in parse_error class which isn't an 8-bit value (json.hpp, line 4440)

2/ JSON_ASSERT(byte < utf8d.size()); (json.hpp, line 18844)
Since byte is declared as an uint8_t, its range is 0 < byte < 256.
This means the assert on an array of size 400 will never fail. VS2019 sometimes produces a warning for this.

3/ JSON_ASSERT(index < 400); (json.hpp, line 18852)
Shouldn't this be
JSON_ASSERT(index < utf8d.size());

Simon

Reproduction steps

"Build"->"Run Code Analyzer on Solution"

Expected vs. actual results

n/a

Minimal code example

No response

Error messages

Warning	C28020	The expression '0<=_Param_(1)&&_Param_(1)<=400-1' is not true at this call.

This message doesn't always show up, I ended up analyzing the code ("Build"->"Run Code Analyzer on Solution")

Compiler and operating system

Windows 10, Microsoft Visual Studio Professional 2019

Library version

version 3.10.4

Validation

Metadata

Metadata

Assignees

Labels

kind: bugsolution: proposed fixa fix for the issue has been proposed and waits for confirmation

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions