[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#930245: libstdc++-6-dev: namespace pollution with low-level macros



Package: libstdc++-6-dev
Version: 6.3.0-18+deb9u1
Severity: normal

$ cat s.cc
#include <iostream>
int major(int x) { return x & ~0xffff; }

$ g++ -E -dD -ansi  s.cc | grep -w major
int major(int x) { return x & ~0xffff; }

$ g++ -E -dD        s.cc | grep -w major
#define major(dev) gnu_dev_major (dev)

Without the -ansi option, iostream pulls sys/sysmacros.h, where 
major() and minor() are defined as macros taking one argument, aliases of
gnu_dev_major/minor.

Likely to cause interesting bugs if one mixes source files with and
without <iostream> includes, or gets library/object order wrong at link time.

Goes undetected until code changes to something like
    int major(std::pair<int,int> x) { return x.first; }
at which point g++ emits a revealing
    error: macro "major" passed 2 arguments, but takes just 1

Not sure if the problem belongs to libstdc++-6-dev, gcc or libc6-dev.

Best regards,
	g

-- System Information:
Debian Release: 9.9
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.9.0-9-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968), LANGUAGE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages libstdc++-6-dev depends on:
ii  gcc-6-base    6.3.0-18+deb9u1
ii  libc6-dev     2.24-11+deb9u4
ii  libgcc-6-dev  6.3.0-18+deb9u1
ii  libstdc++6    6.3.0-18+deb9u1

libstdc++-6-dev recommends no packages.

Versions of packages libstdc++-6-dev suggests:
pn  libstdc++-6-doc  <none>

-- no debconf information


Reply to: