public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101140] New: [modules] no matching function for call to ‘operator new(sizetype, void*)’
@ 2021-06-20 14:52 ensadc at mailnesia dot com
  2021-09-06 11:05 ` [Bug c++/101140] " ensadc at mailnesia dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ensadc at mailnesia dot com @ 2021-06-20 14:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101140
           Summary: [modules] no matching function for call to ‘operator
                    new(sizetype, void*)’
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ensadc at mailnesia dot com
  Target Milestone: ---

$ cat new.hpp
extern "C++" {
void* operator new(__SIZE_TYPE__, void* p);
}

$ cat foo.cpp
module;
#include "new.hpp"
export module foo;

export template<class T>
T* construct_at(T* p) {
    return ::new((void*)p) T();
}

$ cat bar.cpp
export module bar;

import foo;

void f(int* p) {
    construct_at(p);
}

$ g++ -std=c++20 -fmodules-ts -c foo.cpp
$ g++ -std=c++20 -fmodules-ts -c bar.cpp
In module foo, imported at bar.cpp:3:
foo.cpp: In instantiation of ‘T* construct_at@foo(T*) [with T = int]’:
bar.cpp:6:17:   required from here
foo.cpp:7:12: error: no matching function for call to ‘operator new(sizetype,
void*)’
    7 |     return ::new((void*)p) T();
      |            ^~~~~~~~~~~~~~~~~~~
<built-in>: note: candidate: ‘void* operator new(long unsigned int)’
<built-in>: note:   candidate expects 1 argument, 2 provided
<built-in>: note: candidate: ‘void* operator new(long unsigned int,
std::align_val_t)’
<built-in>: note:   no known conversion for argument 2 from ‘void*’ to
‘std::align_val_t’
bar.cpp:1:8: warning: not writing module ‘bar’ due to errors
    1 | export module bar;
      |        ^~~~~~

====

The error disappears if "new.hpp" is included or imported in `bar.cpp`.

I originally encountered this problem when using `std::construct_at` (defined
in`<memory>`) in a module.

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

end of thread, other threads:[~2024-03-26 23:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-20 14:52 [Bug c++/101140] New: [modules] no matching function for call to ‘operator new(sizetype, void*)’ ensadc at mailnesia dot com
2021-09-06 11:05 ` [Bug c++/101140] " ensadc at mailnesia dot com
2022-02-11 12:31 ` asynts+bugs at gmail dot com
2024-03-26 13:54 ` nshead at gcc dot gnu.org
2024-03-26 14:50 ` ppalka at gcc dot gnu.org
2024-03-26 23:54 ` nshead at gcc dot gnu.org

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).