Bug 236784 - lang/gcc8 wrong compiler error message on missing struct member
Summary: lang/gcc8 wrong compiler error message on missing struct member
Status: Closed Not A Bug
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Gerald Pfeifer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-25 14:32 UTC by Michael Buch
Modified: 2019-03-25 14:44 UTC (History)
1 user (show)

See Also:
gerald: maintainer-feedback-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Buch 2019-03-25 14:32:11 UTC
I took this piece of code out of a a project I'm working on:

#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>

struct packet
{
        struct icmp hdr;
};

int main() {
        struct packet pckt;
        memset(&pckt.icmp_data, 0, 0);
        return 0;
}

When compiling this with gcc8 on FreeBSD 12.0-RELEASE I get following error:

bug.c: In function 'main':
bug.c:14:14: error: 'struct packet' has no member named 'icmp_dun'
  memset(&pckt.icmp_data, 0, 0);

gcc is correct in detecting an error since packet indeed has no member "icmp_data" but the error message says "icmp_dun" which appears to come from nowhere.

Unfortunately my only system right now is FreeBSD so couldn't check on other OSes.

Thanks,
Michael
Comment 1 Michael Buch 2019-03-25 14:34:09 UTC
My system info and gcc info:

$> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc8/gcc/x86_64-portbld-freebsd12.0/8.2.0/lto-wrapper
Target: x86_64-portbld-freebsd12.0
Configured with: /wrkdirs/usr/ports/lang/gcc8/work/gcc-8.2.0/configure --with-build-config=bootstrap-debug --disable-nls --enable-gnu-indirect-function --libdir=/usr/local/lib/gcc8 --libexecdir=/usr/local/libexec/gcc8 --program-suffix=8 --with-as=/usr/local/bin/as --with-gmp=/usr/local --with-gxx-include-dir=/usr/local/lib/gcc8/include/c++/ --with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports Collection' --with-system-zlib --enable-languages=c,c++,objc,fortran --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/share/info/gcc8 --build=x86_64-portbld-freebsd12.0
Thread model: posix
gcc version 8.2.0 (FreeBSD Ports Collection)

$> freebsd-version
12.0-RELEASE
Comment 2 Michael Buch 2019-03-25 14:35:00 UTC
Compile command is simply:

gcc bug.c
Comment 3 Gerald Pfeifer freebsd_committer freebsd_triage 2019-03-25 14:44:06 UTC
There isn't much GCC could do differently here, for netinet/ip_icmp.h
that your example includes has the following line: 

  #define	icmp_data	icmp_dun.id_data

In other words, this is not really a GCC issue, but a direct result of
how the FreeBSD system headers are implemented.


In general, for reports that are not FreeBSD-specific, please consider
reporting them upstream, cf. https://gcc.gnu.org/bugs/ .