diff options
author | dlenev@mockturtle.local <> | 2006-10-20 15:47:52 +0400 |
---|---|---|
committer | dlenev@mockturtle.local <> | 2006-10-20 15:47:52 +0400 |
commit | 3fce634fc11344abf4ebac71c921683fcca36a9f (patch) | |
tree | 5b84be9c2183df8cb61c0f7962b707022e594820 /sql/parse_file.h | |
parent | a4826a4233fe415ef70f028f331513108e9989ff (diff) | |
download | mariadb-git-3fce634fc11344abf4ebac71c921683fcca36a9f.tar.gz |
Fix for bug#15228 "'invalid access to non-static data member'
warnings in sql_trigger.cc and sql_view.cc".
According to the current version of C++ standard offsetof() macro
can't be used for non-POD types. So warnings were emitted when we
tried to use this macro for TABLE_LIST and Table_triggers_list
classes. Note that despite of these warnings it was probably safe
thing to do.
This fix tries to circumvent this limitation by implementing
custom version of offsetof() macro to be used with these
classes. This hack should go away once we will refactor
File_parser class.
Alternative approaches such as disabling this warning for
sql_trigger.cc/sql_view.cc or for the whole server were
considered less explicit. Also I was unable to find a way
to disable particular warning for particular _part_ of
file in GCC.
Diffstat (limited to 'sql/parse_file.h')
-rw-r--r-- | sql/parse_file.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sql/parse_file.h b/sql/parse_file.h index 33871588e11..5fb65b4c7ec 100644 --- a/sql/parse_file.h +++ b/sql/parse_file.h @@ -107,4 +107,20 @@ public: bool bad_format_errors); }; + +/* + Custom version of standard offsetof() macro which can be used to get + offsets of members in class for non-POD types (according to the current + version of C++ standard offsetof() macro can't be used in such cases and + attempt to do so causes warnings to be emitted, OTOH in many cases it is + still OK to assume that all instances of the class has the same offsets + for the same members). + + This is temporary solution which should be removed once File_parser class + and related routines are refactored. +*/ + +#define my_offsetof(TYPE, MEMBER) \ + ((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10)) + #endif /* _PARSE_FILE_H_ */ |