After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 767777 - Fix compilation of sigc++/functors/slot.h on non-GCC
Fix compilation of sigc++/functors/slot.h on non-GCC
Status: RESOLVED FIXED
Product: libsigc++
Classification: Bindings
Component: general
2.9.x
Other All
: Normal normal
: ---
Assigned To: libsigc++ maintainer(s)
libsigc++ maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-06-17 06:45 UTC by Fan, Chun-wei
Modified: 2016-06-21 09:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Update to sigc++/functors/macros/slot.h.m4 (1.22 KB, patch)
2016-06-17 06:48 UTC, Fan, Chun-wei
none Details | Review
Update to sigc++/functors/macros/slot.h.m4, with updated commit message (1.25 KB, patch)
2016-06-17 07:42 UTC, Fan, Chun-wei
committed Details | Review
Test case for template keyword (2.23 KB, text/plain)
2016-06-20 14:30 UTC, Kjell Ahlstedt
  Details

Description Fan, Chun-wei 2016-06-17 06:45:48 UTC
Hi,

The commit 6e5eee0 ("Implement slot<R(Arg...)> with variadic template") broke the build of anything on non-GCC that would make use of sigc++/functors/slot.h as the syntax used for calling operator() varies between compiler when used in a variadic templates scenario.

As done elsewhere in the code, we can make use of the SIGC_WORKAROUND_OPERATOR_PARENTHESES to replace "template operator()" so that the correct syntax is used when building code.  I will attach a patch for this shortly.

With blessings, thank you!
Comment 1 Fan, Chun-wei 2016-06-17 06:48:45 UTC
Created attachment 329926 [details] [review]
Update to sigc++/functors/macros/slot.h.m4

Hi,

Here comes the patch.

With blessings, thank you!
Comment 2 Murray Cumming 2016-06-17 06:54:31 UTC
Thanks. This is with the MSVC++ compiler, right? Which version? Please mention that in the commit message.

Are you sure that this is the commit that broke the build?
https://git.gnome.org/browse/libsigcplusplus/commit/?id=6e5eee0
Comment 3 Fan, Chun-wei 2016-06-17 07:42:31 UTC
Created attachment 329927 [details] [review]
Update to sigc++/functors/macros/slot.h.m4, with updated commit message

Hi Murray,

(In reply to Murray Cumming from comment #2)
> Thanks. This is with the MSVC++ compiler, right? Which version? Please
> mention that in the commit message.

Yes indeed, so I added a part that mentions this.  This applies for VS2015 as well.

> Are you sure that this is the commit that broke the build?
> https://git.gnome.org/browse/libsigcplusplus/commit/?id=6e5eee0

Yup, seems like it to me.  The change that made use of template operator() was added there.

It looks like that is the reason why the macro was introduced to cover for that scenario of "template operator()" and "operator()" and the case for the Sun Forte compiler, AFAICT.

With blessings, thank you!
Comment 4 Kjell Ahlstedt 2016-06-19 13:54:33 UTC
This seems to be my fault. But please see what I wrote about
SIGC_CXX_MSVC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD in bug 762065 comment 0.
Bjarne Stroustrup, "The C++ Programming Language", 4th ed., section 26.3.1
has this example:

  template <typename Alloc>
  void f(Alloc& all)
  {
    int* p1 = all.get<int>();          // syntax error: get() is assumed to
                                       // name a non-template
    int* p2 = all.template get<int>(); // OK: get() is assumed to be a template
    // ...
  }

I thought that most compilers by now accepted the syntax that Stroustrup says
is the only correct one.
Comment 5 Fan, Chun-wei 2016-06-20 02:20:21 UTC
Hi Kjell,

I see, the exact error I got was error C2059: syntax error: 'template', so somehow what Stroustrup mentioned did not make it to Visual Studio..., even 2015 :|.

With blessings, thank you!
Comment 6 Kjell Ahlstedt 2016-06-20 14:30:24 UTC
Created attachment 330072 [details]
Test case for template keyword

template operator()<>() or only operator()<>()? It's more difficult than I
thought. See the attached test case.

I've tested your patch with gcc. As expected, no problem. Please push it.

The reason I didn't do it like this in the commit you mention, was probably
that I copied that code from the master branch.
SIGC_WORKAROUND_OPERATOR_PARENTHESES has been removed there, and I didn't
think of adding it in the copy in the libsigc++-2-10 branch.
Comment 7 Fan, Chun-wei 2016-06-21 06:08:37 UTC
Hi Kjell,

Thanks for the test case--I have pushed the patch as ac79b55 in libsigc++-2-10.

I will close the bug now.

With blessings, thank you!
Comment 8 Murray Cumming 2016-06-21 09:21:41 UTC
Thanks, Fan. Maybe you would like to file a bug for the MSVC++ 2015 compiler with Microsoft? They have made many statements recently about wanting to be C++14 compliant, so there is some hope that they might fix this.