Bug 668178 - gcc 4.5 warning
Summary: gcc 4.5 warning
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: gdbm
Version: 14
Hardware: All
OS: All
low
low
Target Milestone: ---
Assignee: Honza Horak
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-01-08 18:01 UTC by Sam Varshavchik
Modified: 2011-02-10 15:03 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-02-10 15:03:02 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Patch to quell the warning (407 bytes, patch)
2011-01-08 18:01 UTC, Sam Varshavchik
no flags Details | Diff

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.


Note You need to log in before you can comment on or make changes to this bug.