Bug #88569 include/my_alloc.h:81:3: error: declaration of ‘block_size’ shadows a member of
Submitted: 21 Nov 2017 1:10 Modified: 13 Nov 2018 17:34
Reporter: George Lorch Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0.3 OS:Debian
Assigned to: CPU Architecture:Any

[21 Nov 2017 1:10] George Lorch
Description:
When compiling a third party storage engine for MySQL 8.0.3 that implements some performance schema counters, we get this error :

In file included from /ssd/percona/8.0/percona-server-8.0/include/my_sys.h:27:0,
                 from /ssd/percona/8.0/percona-server-8.0/include/mysql/psi/mysql_file.h:38,
                 from /ssd/percona/8.0/percona-server-8.0/storage/tokudb/PerconaFT/portability/toku_instr_mysql.h:15,
                 from /ssd/percona/8.0/percona-server-8.0/storage/tokudb/PerconaFT/portability/toku_instrumentation.h:248,
                 from /ssd/percona/8.0/percona-server-8.0/storage/tokudb/PerconaFT/portability/toku_portability.h:153,
                 from /ssd/percona/8.0/percona-server-8.0/storage/tokudb/PerconaFT/portability/file.cc:39:
/ssd/percona/8.0/percona-server-8.0/include/my_alloc.h: In constructor ‘st_mem_root::st_mem_root(PSI_memory_key, size_t, size_t)’:
/ssd/percona/8.0/percona-server-8.0/include/my_alloc.h:81:3: error: declaration of ‘block_size’ shadows a member of 'this' [-Werror=shadow]
   {
   ^

This seems like a valid warning as the code in the struct st_mem_root has this shadow :

  st_mem_root(PSI_memory_key key, size_t block_size, size_t pre_alloc_size)
  {
    init_alloc_root(key, this, block_size, pre_alloc_size);
  }

The struct has a member declared as :
  size_t block_size;               /* initial block size */

How to repeat:
Compile source tree with some file that has __cplusplus defined and include any of the files in the include stack from the error above.

Suggested fix:
Either rename member or rename method parameter.
[13 Nov 2018 14:35] MySQL Verification Team
Hi,

Your concern is valid, but it seems to me that this is a problem that is fixed in 8.0.13.

Can you please try that release ????
[13 Nov 2018 17:34] George Lorch
Yes, you are correct, this has been fixed.  The members of st_mem_root are now all prefixed with 'm_' and are no longer shadowed by member function parameters.  Thank you!
[14 Nov 2018 12:32] MySQL Verification Team
You are truly welcome !!!

For your information the patch is actually pushed in 8.0.11.