*: remove "pure" and "const" attributes from throwing functions
The "pure" and "const" attributes are not so well-defined, and a recent clang version implements an optimization which pushes the definition's boundary beyond what I believed it was. clang now assumes that functions declared "pure" cannot throw exceptions, even if they lack the "noexcept" specification. When compiled with this new clang version, MPD will crash randomly if an exception happens to get thrown by such as "pure" function (https://github.com/MusicPlayerDaemon/MPD/issues/41). This commit removes all such misplaced "pure" and "const" attributes, closing #41.
This commit is contained in:
@@ -129,7 +129,6 @@ ConfigBlock::GetBlockValue(const char *name, unsigned default_value) const
|
||||
return bp->GetUnsignedValue();
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
bool
|
||||
ConfigBlock::GetBlockValue(const char *name, bool default_value) const
|
||||
{
|
||||
|
@@ -44,13 +44,10 @@ struct BlockParam {
|
||||
BlockParam(const char *_name, const char *_value, int _line=-1)
|
||||
:name(_name), value(_value), line(_line), used(false) {}
|
||||
|
||||
gcc_pure
|
||||
int GetIntValue() const;
|
||||
|
||||
gcc_pure
|
||||
unsigned GetUnsignedValue() const;
|
||||
|
||||
gcc_pure
|
||||
bool GetBoolValue() const;
|
||||
};
|
||||
|
||||
@@ -116,13 +113,10 @@ struct ConfigBlock {
|
||||
AllocatedPath GetPath(const char *name,
|
||||
const char *default_value=nullptr) const;
|
||||
|
||||
gcc_pure
|
||||
int GetBlockValue(const char *name, int default_value) const;
|
||||
|
||||
gcc_pure
|
||||
unsigned GetBlockValue(const char *name, unsigned default_value) const;
|
||||
|
||||
gcc_pure
|
||||
bool GetBlockValue(const char *name, bool default_value) const;
|
||||
};
|
||||
|
||||
|
@@ -61,18 +61,9 @@ config_get_block(enum ConfigBlockOption option) noexcept;
|
||||
* @param key the attribute name
|
||||
* @param value the expected attribute value
|
||||
*/
|
||||
gcc_pure
|
||||
const ConfigBlock *
|
||||
config_find_block(ConfigBlockOption option, const char *key, const char *value);
|
||||
|
||||
/* Note on gcc_pure: Some of the functions declared pure are not
|
||||
really pure in strict sense. They have side effect such that they
|
||||
validate parameter's value and signal an error if it's invalid.
|
||||
However, if the argument was already validated or we don't care
|
||||
about the argument at all, this may be ignored so in the end, we
|
||||
should be fine with calling those functions pure. */
|
||||
|
||||
gcc_pure
|
||||
const char *
|
||||
config_get_string(enum ConfigOption option,
|
||||
const char *default_value=nullptr) noexcept;
|
||||
@@ -87,11 +78,9 @@ config_get_string(enum ConfigOption option,
|
||||
AllocatedPath
|
||||
config_get_path(enum ConfigOption option);
|
||||
|
||||
gcc_pure
|
||||
unsigned
|
||||
config_get_unsigned(enum ConfigOption option, unsigned default_value);
|
||||
|
||||
gcc_pure
|
||||
static inline std::chrono::steady_clock::duration
|
||||
config_get_unsigned(ConfigOption option,
|
||||
std::chrono::steady_clock::duration default_value)
|
||||
@@ -101,11 +90,9 @@ config_get_unsigned(ConfigOption option,
|
||||
return std::chrono::steady_clock::duration(u);
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
unsigned
|
||||
config_get_positive(enum ConfigOption option, unsigned default_value);
|
||||
|
||||
gcc_pure
|
||||
static inline std::chrono::steady_clock::duration
|
||||
config_get_positive(ConfigOption option,
|
||||
std::chrono::steady_clock::duration default_value)
|
||||
@@ -115,7 +102,6 @@ config_get_positive(ConfigOption option,
|
||||
return std::chrono::steady_clock::duration(u);
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
bool config_get_bool(enum ConfigOption option, bool default_value);
|
||||
|
||||
#endif
|
||||
|
@@ -71,7 +71,6 @@ struct ConfigParam {
|
||||
*
|
||||
* Throws #std::runtime_error on error.
|
||||
*/
|
||||
gcc_pure
|
||||
AllocatedPath GetPath() const;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user