This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/266: Re: possible pedantic bug
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/266: Re: possible pedantic bug
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Wed, 31 May 2000 08:18:12 +0200
- References: <20000426032314.81425.qmail@hotmail.com>
- Resent-Cc: gcc-prs at gcc dot gnu dot org, j_bouis at hotmail dot com
- Resent-Reply-To: gcc-gnats@gcc.gnu.org, "Martin v. Loewis" <martin@loewis.home.cs.tu-berlin.de>
>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: