public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/62163] New: Dependent function call in constant expression produces error in template definition context
@ 2014-08-17  1:46 hstong at ca dot ibm.com
  2014-12-14  0:25 ` [Bug c++/62163] " ville.voutilainen at gmail dot com
  0 siblings, 1 reply; 2+ messages in thread
From: hstong at ca dot ibm.com @ 2014-08-17  1:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 62163
           Summary: Dependent function call in constant expression
                    produces error in template definition context
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hstong at ca dot ibm.com

GCC does not wait until a (dependent) function call is substituted with
arguments before reporting a hard error in the case below.

It appears that GCC tries to evaluate the constant expression with the lookup
results from the template definition context.

### SOURCE (gccSfinaeDependentConstexpr.cc):
unsigned foo(int);

template <unsigned N> struct Q;

template <typename T> void bar(T, Q<foo(T())> * = 0);
void bar(void *) { }

namespace M {
   struct Z;
   constexpr unsigned foo(Z *) { return 0; }
}

int main() {
   M::Z *p = 0;
   bar(p);
}


### COMPILER OPTIONS:
-std=c++11


### COMPILER OUTPUT:
gccSfinaeDependentConstexpr.cc:5:44: error: call to non-constexpr function
'unsigned int foo(int)'
 template <typename T> void bar(T, Q<foo(T())> * = 0);
                                            ^


### COMPILER VERSION INFO:
Using built-in specs.
COLLECT_GCC=/opt/gcc-4.9.0/bin/g++
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/home/matthew/gcc-4.9.0-prefix
Thread model: posix
gcc version 4.9.0 (GCC)


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

* [Bug c++/62163] Dependent function call in constant expression produces error in template definition context
  2014-08-17  1:46 [Bug c++/62163] New: Dependent function call in constant expression produces error in template definition context hstong at ca dot ibm.com
@ 2014-12-14  0:25 ` ville.voutilainen at gmail dot com
  0 siblings, 0 replies; 2+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-12-14  0:25 UTC (permalink / raw)
  To: gcc-bugs

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

Ville Voutilainen <ville.voutilainen at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-12-14
                 CC|                            |ville.voutilainen at gmail dot com
     Ever confirmed|0                           |1
      Known to fail|                            |4.8.2, 4.9.1, 5.0

--- Comment #1 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
Clang accepts the code.


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

end of thread, other threads:[~2014-12-14  0:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-17  1:46 [Bug c++/62163] New: Dependent function call in constant expression produces error in template definition context hstong at ca dot ibm.com
2014-12-14  0:25 ` [Bug c++/62163] " ville.voutilainen at gmail 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).