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

            Bug ID: 102345
           Summary: [modules] Cannot define a module interface unit for
                    anything in <new>
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

Similar to PR 48396, the implicit declaration of std::align_val_t means you
can't include <new> in a module interface unit.

There are also apparently conflicts between the (correct according to the
standard) new/delete operators, and GCC's built-ins.


export module newdel;
#include <new>



new.cc:5:28: error: cannot define ‘enum class std::align_val_t’ in different
module
    5 |   enum class align_val_t : size_t;
      |                            ^~~~~~
<built-in>: note: declared here
new.cc:5: confused by earlier errors, bailing out
Preprocessed source stored into /tmp/ccZNf6X0.out file, please attach this to
your bugreport.
tmp$ g++20 mod2.cc -fmodules-ts
In file included from mod2.cc:2:
/home/jwakely/gcc/12/include/c++/12.0.0/new:127:41: error: declaration 'void*
operator new(std::size_t)' conflicts with builtin
  127 |   __attribute__((__externally_visible__));
      |                                         ^
/home/jwakely/gcc/12/include/c++/12.0.0/new:129:41: error: declaration 'void*
operator new [](std::size_t)' conflicts with builtin
  129 |   __attribute__((__externally_visible__));
      |                                         ^
/home/jwakely/gcc/12/include/c++/12.0.0/new:131:41: error: declaration 'void
operator delete(void*)' conflicts with builtin
  131 |   __attribute__((__externally_visible__));
      |                                         ^
/home/jwakely/gcc/12/include/c++/12.0.0/new:133:41: error: declaration 'void
operator delete [](void*)' conflicts with builtin
  133 |   __attribute__((__externally_visible__));
      |                                         ^
/home/jwakely/gcc/12/include/c++/12.0.0/new:136:41: error: declaration 'void
operator delete(void*, std::size_t)' conflicts with builtin
  136 |   __attribute__((__externally_visible__));
      |                                         ^
/home/jwakely/gcc/12/include/c++/12.0.0/new:138:41: error: declaration 'void
operator delete [](void*, std::size_t)' conflicts with builtin
  138 |   __attribute__((__externally_visible__));
      |                                         ^
/home/jwakely/gcc/12/include/c++/12.0.0/new:150:73: error: declaration 'void*
operator new(std::size_t, std::align_val_t)' conflicts with builtin
  150 |   __attribute__((__externally_visible__, __alloc_size__ (1),
__malloc__));
      |                                                                        
^
/home/jwakely/gcc/12/include/c++/12.0.0/new:154:63: error: declaration 'void
operator delete(void*, std::align_val_t)' conflicts with builtin
  154 |   _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
      |                                                               ^
/home/jwakely/gcc/12/include/c++/12.0.0/new:158:73: error: declaration 'void*
operator new [](std::size_t, std::align_val_t)' conflicts with builtin
  158 |   __attribute__((__externally_visible__, __alloc_size__ (1),
__malloc__));
      |                                                                        
^
/home/jwakely/gcc/12/include/c++/12.0.0/new:162:63: error: declaration 'void
operator delete [](void*, std::align_val_t)' conflicts with builtin
  162 |   _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
      |                                                               ^
/home/jwakely/gcc/12/include/c++/12.0.0/new:167:63: error: declaration 'void
operator delete(void*, std::size_t, std::align_val_t)' conflicts with builtin
  167 |   _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
      |                                                               ^
/home/jwakely/gcc/12/include/c++/12.0.0/new:169:63: error: declaration 'void
operator delete [](void*, std::size_t, std::align_val_t)' conflicts with
builtin
  169 |   _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
      |                                                               ^
mod2.cc:1:8: warning: not writing module 'newdel' due to errors
    1 | export module newdel;
      |        ^~~~~~

Reply via email to