public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57979] New: G++ accepts constant expression defined using floating point glvalue
@ 2013-07-25  8:13 jogojapan at gmail dot com
  2013-07-25  9:16 ` [Bug c++/57979] G++ accepts constant expression defined using floating point non-constexpr glvalue jogojapan at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jogojapan at gmail dot com @ 2013-07-25  8:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57979

            Bug ID: 57979
           Summary: G++ accepts constant expression defined using floating
                    point glvalue
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jogojapan at gmail dot com

The following code is accepted and compiled without error by G++:

int main()
{
  const float f1 = 0.0;

  constexpr float f2 = f1;

  return 0;
}

Note that the declaration of f2 as constexpr requires f1 to be a constant
expression, which it isn't, according to §5.19/2:

====(QUOTE)========
A condition-expression is a core constant expression unless it involves
[...] 
[..9th item..]
 - an lvalue-to-rvalue conversion (4.1) unless it is applied to [...] a glvalue
of integral or enumeration type that refers to a non-volatile const object with
a preceding initialization, initialized with a constant expresion, or
[...]
====(ENDQUOTE)====

So if f1 had been declared as const int, the code would be acceptable, but
there is no such exception for floating point (or any other non-integral or
non-enum type).


Tested with a 20130708 snapshot checkout from the master branch of the
git-mirror of the repository. (I'll test with a more recent version soon.)
>From gcc-bugs-return-426666-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jul 25 08:20:39 2013
Return-Path: <gcc-bugs-return-426666-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 26049 invoked by alias); 25 Jul 2013 08:20:38 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 25957 invoked by uid 48); 25 Jul 2013 08:20:33 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/57979] G++ accepts constant expression defined using floating point non-constexpr glvalue
Date: Thu, 25 Jul 2013 08:20:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: redi at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed
Message-ID: <bug-57979-4-OwOpt2R7u1@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57979-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57979-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-07/txt/msg01173.txt.bz2
Content-length: 501

http://gcc.gnu.org/bugzilla/show_bug.cgi?idW979

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-07-25
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It's accepted even with -pedantic


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-11-20  3:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-25  8:13 [Bug c++/57979] New: G++ accepts constant expression defined using floating point glvalue jogojapan at gmail dot com
2013-07-25  9:16 ` [Bug c++/57979] G++ accepts constant expression defined using floating point non-constexpr glvalue jogojapan at gmail dot com
2014-09-05  9:38 ` paolo.carlini at oracle dot com
2014-11-18 14:03 ` jason at gcc dot gnu.org
2014-11-18 14:16 ` ville.voutilainen at gmail dot com
2014-11-18 14:17 ` ville.voutilainen at gmail dot com
2014-11-19 22:06 ` jason at gcc dot gnu.org
2014-11-20  3:43 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).