qlibs / sml

C++20 State Machine library
172 stars 7 forks source link

Reference to 'on_exit' is ambigious #6

Closed Qubiz closed 9 months ago

Qubiz commented 9 months ago

On Ubuntu 22.04, when including the sml2 header after the cstdlib header, the compilation fails due to an ambiguous reference to on_exit (see: https://godbolt.org/z/63zef86xo)

#include <cstdlib>
#include "https://raw.githubusercontent.com/boost-ext/sml2/main/sml2"
/app/raw.githubusercontent.com/boost-ext/sml2/main/sml2: In lambda function:
/app/raw.githubusercontent.com/boost-ext/sml2/main/sml2:580:32: error: missing template arguments before '{' token
  580 |         return transition_table{
      |                                ^
/app/raw.githubusercontent.com/boost-ext/sml2/main/sml2:580:32: error: expected ';' before '{' token
  580 |         return transition_table{
      |                                ^
      |                                ;
/app/raw.githubusercontent.com/boost-ext/sml2/main/sml2:583:23: error: reference to 'on_exit' is ambiguous
  583 |              "s2"_s + on_exit / [&] { ++on_exit_calls; },
      |                       ^~~~~~~
In file included from /opt/compiler-explorer/gcc-trunk-20240202/include/c++/14.0.1/cstdlib:79,
                 from <source>:1:
/usr/include/stdlib.h:617:12: note: candidates are: 'int on_exit(void (*)(int, void*), void*)'
  617 | extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
      |            ^~~~~~~

Compiling on Windows using MinGW GCC 13 seems to be fine, as they do not provide the on_exit function.

Specifications