JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 28.0w | AdaCore Inc |
In a legacy structured-binding lookup mode, a tuple-like container has a get member that is not a function, and calling the indexed member fails.
| Class Name | Failed Tuple Container Member Get |
|---|---|
| Significance | style |
| Mnemonic | PARSE.FTCMG |
| Categories | None |
| Availability | Available for C and C++. |
| Enabling | Checks for this warning class are enabled by default.
However, warning instances of this class that are issued as parser
errors (rather than parser warnings)
will be discarded
when using factory configuration settings.
To prevent these instances from being discarded, add the
following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += allow class="Failed Tuple Container Member Get" WARNING_FILTER += discard class="Failed Tuple Container Member Get" |
namespace std {
template<class> struct tuple_size;
template<int, class> struct tuple_element;
}
struct Reading { template<int> static int get; };
namespace std {
template<> struct tuple_size<Reading> { static const int value = 1; };
template<> struct tuple_element<0, Reading> { using type = int; };
}
void inspect(Reading packet)
{
auto [reading] = packet; // 'Failed Tuple Container Member Get' warning issued here
}
To reproduce this example, analyze it with the following configuration:
WARNING_FILTER += allow class="Failed Tuple Container Member Get" # Enable structured bindings in the model's C++14 default mode. EDG_FRONTEND_OPTIONS_APPEND += --cs_struct_bindings # Use the pre-GNU8 member-get rule: this variable template is tried as a # member call, producing the tuple-container diagnostic instead of ADL lookup. COMPILER_MODELS += null-cc -> gpp:64.70000.0.0
This example uses the legacy member lookup behavior of GCC versions before 8. The member variable template produces an integer rather than a callable object. Replacing it with an appropriate function template allows the structured binding to initialize its element.
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.adacore.com/csm.