Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The wrong TLVWriter::Put function will be called with a unsigned 8-bits(or 16-bits) value passed in #7784

Closed
wqx6 opened this issue Jun 21, 2021 · 0 comments

Comments

@wqx6
Copy link
Contributor

wqx6 commented Jun 21, 2021

Problem

After #7746 merged, the compile with our esp-riscv-toolchain fails. The error information shows

../third_party/connectedhomeip/src/app/clusters/door-lock-server/door-lock-server-user.cpp:248:75: error: call of overloaded 'Put(uint64_t, EmberAfDoorLockUserType&)' is ambiguous
../third_party/connectedhomeip/src/app/clusters/door-lock-server/door-lock-server-user.cpp:394:76: error: call of overloaded 'Put(uint64_t, EmberAfDoorLockUserStatus&)' is ambiguous
../third_party/connectedhomeip/src/app/clusters/door-lock-server/door-lock-server-schedule.cpp:506:94: error: call of overloaded 'Put(uint64_t, EmberAfDoorLockOperatingMode&)' is ambiguous

Compile this file test_enum.txt using the command g++ test_enum.cpp and we will get the following results:

input is int32
input is int32
input is uint32

It seems that the enumerations will be cast to int instead of their underlying types if their storage width are not 32-bits.

Then the error of overload ambiguous will appear when int32_t is defined as long(such as our esp-riscv-toolchain and arm-none-eabi-toolchain) and disappear when int32_t is defined as int.

Considering that the resulting TLV just depends on the value passed in and whether it was signed or unsigned, the wrong TLVWriter::Put will be called with a unsigned 8-bits(or 16-bits) value passed in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant