Bug 668178

Summary: gcc 4.5 warning
Product: [Fedora] Fedora Reporter: Sam Varshavchik <mrsam>
Component: gdbmAssignee: Honza Horak <hhorak>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: 14CC: hhorak, kevin, kklic, rdieter
Target Milestone: ---Keywords: Patch
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-02-10 15:03:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch to quell the warning none

Description Sam Varshavchik 2011-01-08 18:01:35 UTC
Created attachment 472369 [details]
Patch to quell the warning

Description of problem:

gcc 4.5 complains when compiling C++ code that include gdbm.h, in some situations. Did not get a response from gdbm's maintainers to the following patch.

Version-Release number of selected component (if applicable):

gdbm-1.8.3-6

How reproducible:

Always

Steps to Reproduce:

$ cat foo.h
#include <gdbm.h>

class xx {

 public:
    GDBM_FILE dbf;

};

[mrsam@octopus tmp]$ cat foo.c
#include "foo.h"
[mrsam@octopus tmp]$ g++ -c foo.c

Actual results:

In file included from foo.c:1:0:
foo.h:3:10: warning: ‘xx’ has a field ‘xx::dbf’ whose type uses the anonymous namespace

Expected results:

Compilation without warnings

Additional info:

Comment 1 Kevin Kofler 2011-01-08 21:17:52 UTC
Isn't that a bug in g++? The type doesn't use the anonymous namespace in the first place.

Comment 2 Sam Varshavchik 2011-01-09 00:40:27 UTC
The typedef in question is a pointer to an anonymous struct.

In C++, an anonymous struct/class is a class that's, essentially, in an anonymous namespace that is unique to each translation unit. In other words, each C++ module sees "GDBM_FILE" as a unique class.

This example is just a warning. gcc will kick it up a notch, and will outright refuse to compile the following self-contained example:

#include <gdbm.h>

void bar(GDBM_FILE *p)
{
}

$ g++ -c foo.c
foo.c:3:22: error: non-local function ‘void bar(<anonymous struct>**)’ uses anonymous type

Since each C++ module thinks GDBM_FILE is a unique class, it can't have external linkage.

Comment 3 Honza Horak 2011-01-13 10:28:51 UTC
The patch seems to solve the warning issue well.

Comment 4 Fedora Update System 2011-01-13 10:55:03 UTC
gdbm-1.8.3-8.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/gdbm-1.8.3-8.fc14

Comment 5 Fedora Update System 2011-01-17 20:54:48 UTC
gdbm-1.8.3-8.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.