This is the mail archive of the gcc-prs@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]

c++/266: Re: possible pedantic bug



>Number:         266
>Category:       c++
>Synopsis:       possible pedantic bug
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          analyzed
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Tue May 30 23:26:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     "Jeff Bouis" <j_bouis@hotmail.com>
>Release:        2.95.2
>Organization:
>Environment:
>Description:
 Original-Message-ID: <20000426032314.81425.qmail@hotmail.com>
 Date: Tue, 25 Apr 2000 20:23:13 PDT

 The following code:

 enum { FOO = 3 };
 int main()
 {
    int* arr = new int[FOO];
    return 0;
 }

 when compiled with the "-pedantic" option will produce the warning

     "warning: size in array new must have integral type"

 This has been tested with version 2.95 under Solaris 2.6, and also with the 
 nightly snapshot validator at http://www.codesourcery.com/gcc-compile.html.

 Replacing FOO with a number (such as 3) in the first line of main() will 
 compile without warnings.

 It is complaining that FOO is not an integral type.  While that is true, the 
 Standard C++ specification seems clear that a conversion from the 
 enumeration to an integral type should happen automatically and implicitly 
 [cf. sections 4 (especially 4.3 and 4.5) and 7.2].  For example, the line
     int bar = FOO;
 compiles without any warnings.  The warning above only occurs when 
 allocating a dynamic array, yet after a careful reading of section 5.3.4 I 
 cannot find any reason that the implicit conversion/promotion should not 
 occur when using new.

 Thanks for your time.

 Jeff Bouis

 ________________________________________________________________________
 Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:

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