public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102345] New: [modules] Cannot define a module interface unit for anything in <new>
@ 2021-09-15 11:21 redi at gcc dot gnu.org
2021-09-15 11:22 ` [Bug c++/102345] " redi at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2021-09-15 11:21 UTC (permalink / raw)
To: gcc-bugs
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;
| ^~~~~~
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/102345] [modules] Cannot define a module interface unit for anything in <new>
2021-09-15 11:21 [Bug c++/102345] New: [modules] Cannot define a module interface unit for anything in <new> redi at gcc dot gnu.org
@ 2021-09-15 11:22 ` redi at gcc dot gnu.org
2021-09-15 11:24 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2021-09-15 11:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102345
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-09-15
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The first problem is demonstrated by:
export module newdel;
namespace std
{
using size_t = decltype(sizeof(0));
enum class align_val_t : size_t;
}
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/cc4qIyxE.out file, please attach this to
your bugreport.
This is fixed by Jason's patch in PR 48396 comment 4.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/102345] [modules] Cannot define a module interface unit for anything in <new>
2021-09-15 11:21 [Bug c++/102345] New: [modules] Cannot define a module interface unit for anything in <new> redi at gcc dot gnu.org
2021-09-15 11:22 ` [Bug c++/102345] " redi at gcc dot gnu.org
@ 2021-09-15 11:24 ` redi at gcc dot gnu.org
2021-09-15 11:24 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2021-09-15 11:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102345
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The second problem is demonstrated by:
export module newdel;
export void* operator new(__SIZE_TYPE__);
new.cc:2:40: error: declaration ‘void* operator new(long unsigned int)’
conflicts with builtin
2 | export void* operator new(__SIZE_TYPE__);
| ^
new.cc:1:8: warning: not writing module ‘newdel’ due to errors
1 | export module newdel;
| ^~~~~~
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/102345] [modules] Cannot define a module interface unit for anything in <new>
2021-09-15 11:21 [Bug c++/102345] New: [modules] Cannot define a module interface unit for anything in <new> redi at gcc dot gnu.org
2021-09-15 11:22 ` [Bug c++/102345] " redi at gcc dot gnu.org
2021-09-15 11:24 ` redi at gcc dot gnu.org
@ 2021-09-15 11:24 ` redi at gcc dot gnu.org
2024-03-13 18:26 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2021-09-15 11:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102345
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
All testcases above need to be compiled with -fmodules-ts
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/102345] [modules] Cannot define a module interface unit for anything in <new>
2021-09-15 11:21 [Bug c++/102345] New: [modules] Cannot define a module interface unit for anything in <new> redi at gcc dot gnu.org
` (2 preceding siblings ...)
2021-09-15 11:24 ` redi at gcc dot gnu.org
@ 2024-03-13 18:26 ` ppalka at gcc dot gnu.org
2024-05-25 0:32 ` cvs-commit at gcc dot gnu.org
2024-05-25 0:34 ` nshead at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-13 18:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102345
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
Keywords|rejects-valid |diagnostic
--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
IIUC we're correct to reject since built-ins are implicitly attached to the
global module and here we're trying to redeclare one in another module?
Perhaps the diagnostic could be improved here though. Clang gives
error: declaration of 'operator new' in module newdel follows declaration in
the global module
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/102345] [modules] Cannot define a module interface unit for anything in <new>
2021-09-15 11:21 [Bug c++/102345] New: [modules] Cannot define a module interface unit for anything in <new> redi at gcc dot gnu.org
` (3 preceding siblings ...)
2024-03-13 18:26 ` ppalka at gcc dot gnu.org
@ 2024-05-25 0:32 ` cvs-commit at gcc dot gnu.org
2024-05-25 0:34 ` nshead at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-25 0:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102345
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nshead@gcc.gnu.org>:
https://gcc.gnu.org/g:28b508233a12c13295f960a2cb8a4864879acfb4
commit r15-830-g28b508233a12c13295f960a2cb8a4864879acfb4
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date: Sat May 25 01:03:54 2024 +1000
c++/modules: Improve diagnostic when redeclaring builtin in module
[PR102345]
If a user mistakenly includes a standard library header within the
module purview, they currently get a confusing "declaration conflicts
with builtin" error. This patch updates the message to include "in
module", to help guide the user towards the likely cause.
PR c++/102345
gcc/cp/ChangeLog:
* module.cc (module_may_redeclare): Update error message.
gcc/testsuite/ChangeLog:
* g++.dg/modules/enum-12.C: Test for updated error.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/102345] [modules] Cannot define a module interface unit for anything in <new>
2021-09-15 11:21 [Bug c++/102345] New: [modules] Cannot define a module interface unit for anything in <new> redi at gcc dot gnu.org
` (4 preceding siblings ...)
2024-05-25 0:32 ` cvs-commit at gcc dot gnu.org
@ 2024-05-25 0:34 ` nshead at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-05-25 0:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102345
Nathaniel Shead <nshead at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |nshead at gcc dot gnu.org
Resolution|--- |FIXED
--- Comment #6 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
The diagnostic now reads:
e.cpp:2:14: error: declaring ‘void* operator new(long unsigned int)’ in module
‘newdel’ conflicts with builtin in global module
2 | export void* operator new(__SIZE_TYPE__);
| ^~~~~~~~
e.cpp:1:8: warning: not writing module ‘newdel’ due to errors
1 | export module newdel;
| ^~~~~~
which should be clearer as to what the issue is.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-05-25 0:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-15 11:21 [Bug c++/102345] New: [modules] Cannot define a module interface unit for anything in <new> redi at gcc dot gnu.org
2021-09-15 11:22 ` [Bug c++/102345] " redi at gcc dot gnu.org
2021-09-15 11:24 ` redi at gcc dot gnu.org
2021-09-15 11:24 ` redi at gcc dot gnu.org
2024-03-13 18:26 ` ppalka at gcc dot gnu.org
2024-05-25 0:32 ` cvs-commit at gcc dot gnu.org
2024-05-25 0:34 ` 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).