https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68784
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Wang Xuancong from comment #0) > g++ require explicit reference cast: > t[0] = thread(thread_add, ref(ht), 0, 9); With that change your program has a data race due to modifying the same object in two separate threads, which leads to undefined behaviour. You should get a good book and read it carefully.