public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100498] New: SFINAE and static inline function
@ 2021-05-10  9:05 wolfgang.roehrl@gi-de.com
  2021-05-10  9:48 ` [Bug c++/100498] " redi at gcc dot gnu.org
  2021-05-17 12:35 ` wolfgang.roehrl@gi-de.com
  0 siblings, 2 replies; 3+ messages in thread
From: wolfgang.roehrl@gi-de.com @ 2021-05-10  9:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100498
           Summary: SFINAE and static inline function
           Product: gcc
           Version: 7.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wolfgang.roehrl@gi-de.com
  Target Milestone: ---

Hi,

I would like to post a bug report for the GNU C/C++ compiler 7.5.0.

We use the compiler to generate code for a PowerPC processor.

Invokation line for the GNU C++ compiler:

ccppc -c -x c++ --std=gnu++17 -Wall -Werror -g -mcpu=e6500 -m32
      -maltivec -mvrsave -ftls-model=local-exec -msdata=sysv
      -fno-common -fno-openmp -mbig -mmultiple -mno-string -misel
      -mstrict-align -fverbose-asm -G 8 -O3
      -I<some include paths>
      -D<some #define's>
      X.CPP -oX.O

// file X.CPP

void f1 (int) {}
inline void f1 (float) {}

struct X
{
    friend void f1 (int*) {}
};
void f1 (int*);


template <typename F_, typename = void>
struct SFINAE
{ static constexpr F_* ptr = nullptr; };

template <typename F_>
struct SFINAE< F_, decltype((void)static_cast<F_*>(f1), void()) >
{ static constexpr F_* ptr = f1; };


void func ()
{
    using F1 = void(int);
    constexpr F1* ptr1{ SFINAE<F1>::ptr };
    static_assert (ptr1 != nullptr);

    using F2 = void(float);
    constexpr F2* ptr2{ SFINAE<F2>::ptr };
    static_assert (ptr2 != nullptr);

    using F3 = void(int*);
    constexpr F3* ptr3{ SFINAE<F3>::ptr };
    static_assert (ptr3 != nullptr);
}


Wenn we compile this program we get the following error messages:
x.CPP: In function 'void func()':
x.CPP:29:5: error: non-constant condition for static assertion
     static_assert (ptr2 != nullptr);
     ^~~~~~~~~~~~~
x.CPP:29:25: error: '(f1 != 0)' is not a constant expression
     static_assert (ptr2 != nullptr);
                    ~~~~~^~~~~~~~~~
x.CPP:33:5: error: non-constant condition for static assertion
     static_assert (ptr3 != nullptr);
     ^~~~~~~~~~~~~
x.CPP:33:25: error: '(f1 != 0)' is not a constant expression
     static_assert (ptr3 != nullptr);
                    ~~~~~^~~~~~~~~~

The reason for the first error messages is the inline attribute of function
"void f1 (float)"; the error messages disappear if "inline" is removed. I
I think this is not standard compliant.
A similar problem seems to arise with function "void f1 (int*)". 


With kind regards
W. Roehrl

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

* [Bug c++/100498] SFINAE and static inline function
  2021-05-10  9:05 [Bug c++/100498] New: SFINAE and static inline function wolfgang.roehrl@gi-de.com
@ 2021-05-10  9:48 ` redi at gcc dot gnu.org
  2021-05-17 12:35 ` wolfgang.roehrl@gi-de.com
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2021-05-10  9:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Wolfgang Roehrl from comment #0)
> I would like to post a bug report for the GNU C/C++ compiler 7.5.0.

Please don't :-)

The oldest supported release is 8.4.0 and even the 8,x branch is almost out of
support, so please try using a current release before reporting bugs.

This was already fixed by this commit:

    PR c++/80485 - inline function non-zero address.

            * symtab.c (nonzero_address): Check DECL_COMDAT.

    From-SVN: r260762

Your code works correctly in GCC 8.2.0 and later

*** This bug has been marked as a duplicate of bug 80485 ***

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

* [Bug c++/100498] SFINAE and static inline function
  2021-05-10  9:05 [Bug c++/100498] New: SFINAE and static inline function wolfgang.roehrl@gi-de.com
  2021-05-10  9:48 ` [Bug c++/100498] " redi at gcc dot gnu.org
@ 2021-05-17 12:35 ` wolfgang.roehrl@gi-de.com
  1 sibling, 0 replies; 3+ messages in thread
From: wolfgang.roehrl@gi-de.com @ 2021-05-17 12:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Wolfgang Roehrl <wolfgang.roehrl@gi-de.com> ---
@Jonathan Wakely: 
Thank you very much for the detailled answer. Using this info
it was possible for us to patch our 7.5 compiler version. At the moment we are
constrained to use a 7.x compiler because we need support for the PowerPC e500
core. (To our knowledge this support has been phased out with the 8.x
versions.)

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

end of thread, other threads:[~2021-05-17 12:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10  9:05 [Bug c++/100498] New: SFINAE and static inline function wolfgang.roehrl@gi-de.com
2021-05-10  9:48 ` [Bug c++/100498] " redi at gcc dot gnu.org
2021-05-17 12:35 ` wolfgang.roehrl@gi-de.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).