From: Daniel Berlin <dan@cgsoftware.com>
To: Eli Zaretskii <eliz@is.elta.co.il>
Cc: jimb@zwingli.cygnus.com, msnyder@redhat.com,
gdb-patches@sources.redhat.com, ac131313@cygnus.com
Subject: Re: [RFA] enum enable
Date: Wed, 18 Jul 2001 00:34:00 -0000 [thread overview]
Message-ID: <871yne8zcu.fsf@cgsoftware.com> (raw)
In-Reply-To: <200107180700.KAA12466@is.elta.co.il>
Eli Zaretskii <eliz@is.elta.co.il> writes:
>> From: Jim Blandy <jimb@zwingli.cygnus.com>
>> Date: 17 Jul 2001 12:46:32 -0500
>>
>> Eli Zaretskii <eliz@is.elta.co.il> writes:
>> > In addition to Andrew's request to change that, GCC 2.7.2.1 barfs if
>> > it sees the declaration of a member `enable' together with a prototype
>> > of a function `enable' in the same compilation unit. In my case, the
>> > function is declared in one of the system headers, so I guess GCC sees
>> > it first and protests when the same identifier appears in a struct.
>>
>> You've *got* to be kidding.
>>
>> So, the following program gets an error?
>>
>> extern int foo (void);
>>
>> struct bar
>> {
>> int foo;
>> };
>>
>
> No, that one passes. But this one does not:
>
> enum foobar
> {
> foo,
> bar
> };
>
> int foo(void);
>
> $ gcc2721 -c enum.c
> enum.c:8: two or more data types in declaration of `foo'
> enum.c:8: `foo' redeclared as different kind of symbol
> enum.c:4: previous declaration of `foo'
>
> If I switch the order of the function and enum declaration, the
> resulting message might give a clue about what's going on:
>
> int foo(void);
>
> enum foobar
> {
> foo,
> bar
> };
>
> $ gcc2721 -c enum.c
> enum.c:6: `foo' redeclared as different kind of symbol
> enum.c:2: previous declaration of `foo'
> enum.c:6: warning: `foo' was declared `extern' and later `static'
>
> Actually, now I see that even GCC 2.95.3 reports the same errors.
>
> [Dig, dig] and it looks like this is expected: my references indicate
> that enumeration constants and function names belong to the same
> namespace in C programs.
Yeah, but in case you still thought gcc was off the hook for this type
of failure, check this out:
#include <vector>
struct fill {}; // comment out this line to compile successfully
struct y {};
void f()
{
std::vector<y> x(10);
x.insert(x.begin(), 10, y());
}
Works fine with 2.95. Perfectly valid C++.
Fails miserably with 3.0.
Whoops.
:)
--Dan
--
"Women... Can't live with 'em... Can't shoot 'em.
"-Steven Wright
next prev parent reply other threads:[~2001-07-18 0:34 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.SUN.3.91.1010711161311.5321C-100000@is>
[not found] ` <3B4E41B5.64FB@redhat.com>
2001-07-14 4:08 ` Eli Zaretskii
2001-07-16 14:52 ` Jim Blandy
2001-07-16 15:53 ` Andrew Cagney
2001-07-17 0:06 ` Eli Zaretskii
2001-07-17 10:45 ` Jim Blandy
[not found] ` <200107180700.KAA12466@is.elta.co.il>
2001-07-18 0:34 ` Daniel Berlin [this message]
2001-07-18 10:15 ` Jim Blandy
2001-07-18 12:59 ` Eli Zaretskii
2001-07-19 5:57 ` Michael Snyder
2001-07-19 6:13 ` Eli Zaretskii
[not found] ` <npzoa4y1hp.fsf@zwingli.cygnus.com>
2001-07-17 0:07 ` Eli Zaretskii
2001-07-25 7:28 ` Eli Zaretskii
2001-07-30 16:24 ` Jim Blandy
2001-07-31 1:45 ` Eli Zaretskii
2001-07-31 16:24 ` Jim Blandy
2001-07-31 16:33 ` Jim Blandy
2001-08-01 1:53 ` Eli Zaretskii
2001-08-01 14:05 ` Andrew Cagney
2001-08-01 21:52 ` Jim Blandy
2001-08-02 5:07 ` Eli Zaretskii
2001-07-29 0:49 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871yne8zcu.fsf@cgsoftware.com \
--to=dan@cgsoftware.com \
--cc=ac131313@cygnus.com \
--cc=eliz@is.elta.co.il \
--cc=gdb-patches@sources.redhat.com \
--cc=jimb@zwingli.cygnus.com \
--cc=msnyder@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox