-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Labels
solution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation
Milestone
Description
Description
(Yes, I have read #3827, #4038, #4039 and #4205)
The original compiler error in #3827 is because in a template context, the compiler (GCC) cannot infer that the type of value is const nlohmann::json &, thus .template get is needed.
However, this seems to be a bug of GCC, because key is extracted from sourceData.items(), and sourceData is not dependent on template variables K or V.
I suggest to remove most of the template keyword when not required i.e. not in a template context, as suggested in #4205, because:
.template getis unnecessary in a non-template context. See the code in #3827 but whenconvertis a regular function, this compiled with gcc 12.4 without error.- GCC fixed this in 13.1. The original code (https://godbolt.org/z/Gxv7dbsjW) compiles correctly with the latest GCC.
- Excessive use of
.template getin the documentation makes the code too verbose, and might recommend the users to use theget_toAPI, which separates the definition and initiation and is not ideal.
Reproduction steps
Ran some tests in compiler explorer:
- The original code, won't compile with GCC 12.4. link
- The original code, compiles correctly with GCC 13.1. link
- The original code but
convertis converted into a regular function, compiles without error in GCC 12.4. link
Expected vs. actual results
Should remove the template keywords not in actual template definitions.
Minimal code example
Error messages
Compiler and operating system
GCC 12.4 and GCC 13.1
Library version
develop branch
Validation
- The bug also occurs if the latest version from the
developbranch is used. - I can successfully compile and run the unit tests.
Metadata
Metadata
Assignees
Labels
solution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation