public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51912] New: [C++11] G++ accepts floating point case labels
@ 2012-01-20  7:46 jason at gcc dot gnu.org
  2012-02-15 16:21 ` [Bug c++/51912] " paolo.carlini at oracle dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2012-01-20  7:46 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51912
           Summary: [C++11] G++ accepts floating point case labels
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jason@gcc.gnu.org


5.19:  A converted constant expression of type T is a literal constant
expression, implicitly converted to type T, where the implicit conversion (if
any) is permitted in a literal constant expression and the implicit conversion
sequence contains only user-defined  conversions, lvalue-to-rvalue conversions
(4.1), integral promotions (4.5), and integral conversions (4.7) other than
narrowing conversions (8.5.4). [ Note: such expressions may be used as case
expressions (6.4.2), ....

So a floating point literal is not a valid case expression, since converting it
to the switch type would require a non-integral conversion.

void f(int i)
{
  switch (i)
    {
    case 1.0:;
    }
}


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

end of thread, other threads:[~2013-08-14 21:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-20  7:46 [Bug c++/51912] New: [C++11] G++ accepts floating point case labels jason at gcc dot gnu.org
2012-02-15 16:21 ` [Bug c++/51912] " paolo.carlini at oracle dot com
2012-02-15 16:41 ` paolo.carlini at oracle dot com
2012-05-29 14:02 ` paolo.carlini at oracle dot com
2013-08-14 18:01 ` paolo.carlini at oracle dot com
2013-08-14 21:44 ` paolo.carlini at oracle dot com

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).