@@ -51,17 +51,7 @@ ifelse($1,0,[dnl
51
51
* @return The slot's return value.
52
52
*/
53
53
T_return operator()(const slot_type& _A_slot) const
54
- {
55
- // Conversion between different types of function pointers with
56
- // reinterpret_cast can make gcc8 print a warning.
57
- // https://github.com/libsigcplusplus/libsigcplusplus/issues/1
58
- union {
59
- internal::hook ph;
60
- typename slot_type::call_type pc;
61
- } u;
62
- u.ph = _A_slot.rep_->call_;
63
- return (u.pc)(LIST(_A_slot.rep_, LOOP(_A_a%1_, $1 )));
64
- }
54
+ { return (reinterpret_cast<typename slot_type::call_type>(_A_slot.rep_->call_))(LIST(_A_slot.rep_, LOOP(_A_a%1_, $1 ))); }
65
55
dnl T_return operator()(const slot_type& _A_slot) const
66
56
dnl { return _A_slot(LOOP(_A_a%1_, $1 )); }
67
57
@@ -160,19 +150,13 @@ FOR(1, $1,[
160
150
if (it == slots.end())
161
151
return T_return(); // note that 'T_return r_();' doesn't work => define 'r_' after this line and initialize as follows:
162
152
163
- union {
164
- internal::hook ph;
165
- call_type pc;
166
- } u;
167
- u.ph = it->rep_->call_;
168
- r_ = (u.pc)(LIST(it->rep_, LOOP(_A_a%1, $1 )));
153
+ r_ = (reinterpret_cast<call_type>(it->rep_->call_))(LIST(it->rep_, LOOP(_A_a%1, $1 )));
169
154
for (++it; it != slots.end(); ++it)
170
- {
171
- if (it->empty() || it->blocked())
172
- continue;
173
- u.ph = it->rep_->call_;
174
- r_ = (u.pc)(LIST(it->rep_, LOOP(_A_a%1, $1 )));
175
- }
155
+ {
156
+ if (it->empty() || it->blocked())
157
+ continue;
158
+ r_ = (reinterpret_cast<call_type>(it->rep_->call_))(LIST(it->rep_, LOOP(_A_a%1, $1 )));
159
+ }
176
160
}
177
161
178
162
return r_;
@@ -217,19 +201,13 @@ FOR(1, $1,[
217
201
if (it == reverse_iterator_type(slots.begin()))
218
202
return T_return(); // note that 'T_return r_();' doesn't work => define 'r_' after this line and initialize as follows:
219
203
220
- union {
221
- internal::hook ph;
222
- call_type pc;
223
- } u;
224
- u.ph = it->rep_->call_;
225
- r_ = (u.pc)(LIST(it->rep_, LOOP(_A_a%1, $1 )));
204
+ r_ = (reinterpret_cast<call_type>(it->rep_->call_))(LIST(it->rep_, LOOP(_A_a%1, $1 )));
226
205
for (++it; it != reverse_iterator_type(slots.begin()); ++it)
227
- {
228
- if (it->empty() || it->blocked())
229
- continue;
230
- u.ph = it->rep_->call_;
231
- r_ = (u.pc)(LIST(it->rep_, LOOP(_A_a%1, $1 )));
232
- }
206
+ {
207
+ if (it->empty() || it->blocked())
208
+ continue;
209
+ r_ = (reinterpret_cast<call_type>(it->rep_->call_))(LIST(it->rep_, LOOP(_A_a%1, $1 )));
210
+ }
233
211
}
234
212
235
213
return r_;
@@ -265,17 +243,12 @@ FOR(1, $1,[
265
243
signal_exec exec(impl);
266
244
temp_slot_list slots(impl->slots_);
267
245
268
- union {
269
- internal::hook ph;
270
- call_type pc;
271
- } u;
272
246
for (const auto& slot : slots)
273
- {
274
- if (slot.empty() || slot.blocked())
275
- continue;
276
- u.ph = slot.rep_->call_;
277
- (u.pc)(LIST(slot.rep_, LOOP(_A_a%1, $1 )));
278
- }
247
+ {
248
+ if (slot.empty() || slot.blocked())
249
+ continue;
250
+ (reinterpret_cast<call_type>(slot.rep_->call_))(LIST(slot.rep_, LOOP(_A_a%1, $1 )));
251
+ }
279
252
}
280
253
281
254
_DEPRECATE_IFDEF_START
@@ -301,17 +274,12 @@ FOR(1, $1,[
301
274
typedef std::reverse_iterator<signal_impl::iterator_type, std::random_access_iterator_tag,
302
275
slot_base, slot_base&, slot_base*, std::ptrdiff_t> reverse_iterator_type;
303
276
#endif
304
- union {
305
- internal::hook ph;
306
- call_type pc;
307
- } u;
308
277
for (auto it = reverse_iterator_type(slots.end()); it != reverse_iterator_type(slots.begin()); ++it)
309
- {
310
- if (it->empty() || it->blocked())
311
- continue;
312
- u.ph = it->rep_->call_;
313
- (u.pc)(LIST(it->rep_, LOOP(_A_a%1, $1 )));
314
- }
278
+ {
279
+ if (it->empty() || it->blocked())
280
+ continue;
281
+ (reinterpret_cast<call_type>(it->rep_->call_))(LIST(it->rep_, LOOP(_A_a%1, $1 )));
282
+ }
315
283
}
316
284
_DEPRECATE_IFDEF_END
317
285
};
0 commit comments