This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: enums and null pointer constants


Zack Weinberg wrote:
> Taken together, I believe this means that an enum with value 0 is to
> be considered a null pointer constant, so the comment and the build1
> operation are incorrect.

I agree. This is also a C++ issue.

FYI I submitted this comment on C++ Core issue 74 (you
should be able to find it via dejanews)
<quote>
Subject: DR: Core Issue 74
        Date:Thu, 24 Feb 2000 15:45:32 +0000
        From:  Nathan Sidwell <nathan@codesourcery.com>
Organization: CodeSourcery, LLC
  Newsgroups:comp.lang.c++

Hi,
this is about core issue 74
(http://www.informatik.hu-berlin.de/~loewis/corer8.html#74)

That issue is incomplete. The same requirement for an integral constant
expression is made in (at least) three places
1) null pointer constant (expression must be of value zero) [conv.ptr][4.10]/1
2) array bounds declaration [dcl.array][8.3.4]/1
3) array new [expr.new][5.3.4]/6

The report should address all three issues, not just the last one.

However, in light of  [conv] [4]/1 which says
        `A standard conversion sequence will be applied to an an
        expression if necessary to convert it to a required destination type.'
I believe this is NAD, in that the enumeration type can be implicitly
converted to integral type. The following program should compile without
error

        enum E {e = 0, f = 1};

        void fn (void *);

        void foo ()
        {
          fn (e);
          int ary[f];
          int *p0 = new int[f];
          int (*p1)[1] = new int[f][1];
        }
</quote>

Also the bug report at http://gcc.gnu.org/ml/gcc-bugs/2000-02/msg00361.html

Mark, I take it from your comments, that this should be fixed.

nathan

-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]