This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/79592] incomplete diagnostic "is not usable as a constexpr function because:"


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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-08-21
                 CC|                            |egallager at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #0)
> struct pthread_mutex {
>   void *m_ptr;
> };
> 
> struct M {
>   pthread_mutex m = { ((void *) 1LL) };
> };
> 
> constexpr M m;
> 
> pt.cc:9:13: error: ‘constexpr M::M()’ called in a constant expression
>  constexpr M m;
>              ^
> pt.cc:5:8: note: ‘constexpr M::M()’ is not usable as a constexpr function
> because:
>  struct M {
>         ^
> 
> It just says "because:" without saying what the problem is (the cast is not
> allowed in a constant expression).
> 
> If the expression is (void*)1 rather than (void*)1LL then it is incorrectly
> accepted.

On a 32-bit target, it is always incorrectly accepted; adding -m64 is necessary
to get the incomplete diagnostic:

$ /usr/local/bin/g++ -c -Wall -Wextra -pedantic -std=c++11 79592.cc
$ /usr/local/bin/g++ -c -Wall -Wextra -pedantic -std=c++11 -m64 79592.cc
79592.cc:9:13: error: ‘constexpr M::M()’ called in a constant expression
 constexpr M m;
             ^
79592.cc:5:8: note: ‘constexpr M::M()’ is not usable as a constexpr function
because:
 struct M {
        ^
$

Confirmed.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]