Bug #7851 C++ 'new' conflicts with kernel header asm/system.h
Submitted: 12 Jan 2005 23:43 Modified: 27 Jun 2005 11:48
Reporter: Beau E. Cox Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:4.1 OS:Linux (Linux)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[12 Jan 2005 23:43] Beau E. Cox
Description:
Since Linux kernel 2.6.10-prexx the folliowing error occurs in my_new.cc:

if g++ -DDEFAULT_BASEDIR=\"/usr\" -DDATADIR="\"/var/lib/mysql\"" -DDEFAULT_CHARSET_HOME="\"/usr\"" -DSHAREDIR="\"/usr/share/mysql\"" -DDEFAULT_HOME_ENV=MYSQL_HOME -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I.    -O3 -DDBUG_OFF -O2 -pipe -march=athlon-xp  -O3 -felide-constructors -fno-exceptions -fno-rtti -DHAVE_ERRNO_AS_DEFINE=1   -fno-implicit-templates -fno-exceptions -fno-rtti -MT my_new.o -MD -MP -MF ".deps/my_new.Tpo" -c -o my_new.o my_new.cc; \
then mv -f ".deps/my_new.Tpo" ".deps/my_new.Po"; else rm -f ".deps/my_new.Tpo"; exit 1; fi
In file included from /usr/include/asm/processor.h:18,
                 from /usr/include/asm/atomic.h:6,
                 from ../include/my_global.h:293,
                 from mysys_priv.h:17,
                 from my_new.cc:22:
/usr/include/asm/system.h:247: error: expected `,' or `...' before "new"
/usr/include/asm/system.h: In function `long unsigned int __cmpxchg(volatile void*, long unsigned int, long unsigned int)':
/usr/include/asm/system.h:250: error: `size' undeclared (first use this function)
/usr/include/asm/system.h:250: error: (Each undeclared identifier is reported only once for each function it appears in.)
/usr/include/asm/system.h:254: error: expected identifier before ')' token
/usr/include/asm/system.h:260: error: expected identifier before ')' token
/usr/include/asm/system.h:266: error: expected identifier before ')' token
make[2]: *** [my_new.o] Error 1

It seems the c++ 'new' is crossing the '#ifdef __cpluscplus__ ...' boundry and causing this error. I am using gnu tools: gccversion='3.4.3', gnulibc_version='2.3.3'.

How to repeat:
Compile with kernel 2.6.10+ using current gcc+glibc.

Suggested fix:
I can't understand how 'new' is confusing the plain c kernel headers. I cannot find any mysql problem - this is possibly a gnu-gcc problem ( they say no ).

My workaround is to patch asm/system.h:

sed -i "s/new/nneww/g" /usr/include/asm/system.h 

( my kernel headers are put there after kernel compiles ).
[1 Feb 2005 14:46] Aleksey Kishkin
tested on slackware 10 with kernel 2.6.10 (after patch according bug #7970)
[9 Feb 2005 15:58] Arnar Birgisson
This bug also affects MySQL 4.1.9 (tested on Slackware 10.1, linux 2.6.10, gcc 3.3.4).
[16 Jun 2005 10:59] Sebastian Lehn
This bug also affects MySQL 4.1.9 (tested on Slackware 10.1, linux 2.6.10, gcc
3.3.4).
Bug exist already at MySQL 4.1.12 (tested on Slackware 10.0, linux 2.6.11.12, gcc 3.3.4)
[16 Jun 2005 11:00] Sebastian Lehn
Bug exist already at MySQL 4.1.12 (tested on Slackware 10.0, linux 2.6.11.12, gcc 3.3.4)
[16 Jun 2005 12:25] Sergei Golubchik
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

fixed in 4.1.13
[22 Jun 2005 20:51] Bauke Jan Douma
This bug is (still) present in 5.0.8 beta.  So no, not fixed, and should not be closed.

Things like this (and thinking of how long it took to fix the NPTL vs. LinuxThreads
issue) really turn me off of mysql.  For a good understanding -- that is my loss too.

Thanks for your time.

bjd
[23 Jun 2005 20:24] Sergei Golubchik
what bug is not fixed ? could you report it separately please ?
(it must be a different bug, because this bug - 7851 - *is* fixed, I see the fix in the source)
[23 Jun 2005 20:26] Sergei Golubchik
ehm, sorry. Ramil, could you remove

#if defined(__ia64__)

from your patch please ? :)
[24 Jun 2005 7:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/26396
[24 Jun 2005 8:02] Ramil Kalimullin
done in 4.1