public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ensadc at mailnesia dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/101140] New: [modules] no matching function for call to ‘operator new(sizetype, void*)’
Date: Sun, 20 Jun 2021 14:52:26 +0000	[thread overview]
Message-ID: <bug-101140-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2021-06-20 14:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-20 14:52 ensadc at mailnesia dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-101140-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).