public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52966] New: ill-formed template constexpr functions are accepted?
@ 2012-04-12 23:45 drwowe at yahoo dot com
  2015-07-18 15:43 ` [Bug c++/52966] " yury at shurup dot com
  0 siblings, 1 reply; 2+ messages in thread
From: drwowe at yahoo dot com @ 2012-04-12 23:45 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52966
           Summary: ill-formed template constexpr functions are accepted?
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: drwowe@yahoo.com


The following code successfully compiles on g++ 4.7.0 with -std=c++11.  I'm not
a language lawyer, but it seems like it shouldn't since the A::two() function
breaks the constexpr rules, either at template definition or template
instantiation time.

------
template<class T>
struct A {
  static int two_nonconst() { return 2; }
  static constexpr int two() { return two_nonconst(); }
}

constexpr int two() {
  return A<int>::two();
}
------

There is no error message until you actually try to use the two() function in
an appropriate context, which could be very confusing.

------
int x[two()];
------
error: size of array 'x' is not an integral constant-expression


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

* [Bug c++/52966] ill-formed template constexpr functions are accepted?
  2012-04-12 23:45 [Bug c++/52966] New: ill-formed template constexpr functions are accepted? drwowe at yahoo dot com
@ 2015-07-18 15:43 ` yury at shurup dot com
  0 siblings, 0 replies; 2+ messages in thread
From: yury at shurup dot com @ 2015-07-18 15:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52966

Yury V. Zaytsev <yury at shurup dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yury at shurup dot com

--- Comment #1 from Yury V. Zaytsev <yury at shurup dot com> ---
I've been also hit by this bug recently on gcc 4.9.2 and gcc 5.1. I haven't
tried gcc 5.2 yet, but I would assume it's still there.


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

end of thread, other threads:[~2015-07-18 15:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-12 23:45 [Bug c++/52966] New: ill-formed template constexpr functions are accepted? drwowe at yahoo dot com
2015-07-18 15:43 ` [Bug c++/52966] " yury at shurup 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).