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

Bug#941911: g++: Broken -x/suffix handling leads to spurious -Wc++-compat warnings



Package: g++-8
Version: 8.3.0-6
Severity: normal

Dear Maintainer,

I noticed a bug in handling -Wc++-compat when (not) using the -x option.
Suppose you have two files containing valid C saved in files a.c and b.c,
for example, "int main(void) {}" in a.c and just a newline in b.c.

According to the documentation AFAICT you should be able to compile this
without errors in a single step by executing
        g++ -Wc++-compat a.c b.c
since the correct language of the file should be determined automatically by
the suffix.

However, this leads to two times
        cc1plus: warning: command line option ‘-Wc++-compat’ is valid for
C/ObjC but not for C++

One should be able to remove the warnings by forcing the language used to C
by prepending "-x c" as in
        g++ -Wc++-compat -x c a.c b.c
since the manual states that -x <lang> "applies to all following input files
until the next -x option".

However, this is not the case because only the first spurious warning is fixed
by this and ony adding another -x c just before the second file, i.e.,
        g++ -Wc++-compat -x c a.c -x c b.c
works as expected without any warnings.

This problem is not depending on any arch specifics (tested with native g++
8.3.0
on amd64, and cross compilers for riscv64-linux-gnu, and arm-linux-gnueabihf).
A quick test with g++ 6.3.0-18+deb9u1 on amd64 revealed the same behavior.

I did not (and do not intend to but could if need be) report this upstream.

KR, Stefan



-- System Information:
Debian Release: 10.1
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable'), (91, 'testing'), (10, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.0-6-amd64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_WARN, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages g++-8 depends on:
ii  gcc-8            8.3.0-6
ii  gcc-8-base       8.3.0-6
ii  libc6            2.28-10
ii  libgmp10         2:6.1.2+dfsg-4
ii  libisl19         0.20-2
ii  libmpc3          1.1.0-1
ii  libmpfr6         4.0.2-1
ii  libstdc++-8-dev  8.3.0-6
ii  zlib1g           1:1.2.11.dfsg-1

g++-8 recommends no packages.

Versions of packages g++-8 suggests:
pn  g++-8-multilib    <none>
ii  gcc-8-doc         8.3.0-1~bpo10+1
pn  libstdc++6-8-dbg  <none>

-- no debconf information


Reply to: