* [Bug c++/48396] Undeclared library types accepted in namespace std
2011-03-31 23:33 [Bug c++/48396] New: Undeclared library types accepted in namespace std paolo.carlini at oracle dot com
@ 2012-04-12 12:25 ` redi at gcc dot gnu.org
2021-03-05 10:09 ` [Bug c++/48396] std::type_info is implicitly declared redi at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2012-04-12 12:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48396
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-04-12
Ever Confirmed|0 |1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/48396] std::type_info is implicitly declared
2011-03-31 23:33 [Bug c++/48396] New: Undeclared library types accepted in namespace std paolo.carlini at oracle dot com
2012-04-12 12:25 ` [Bug c++/48396] " redi at gcc dot gnu.org
@ 2021-03-05 10:09 ` redi at gcc dot gnu.org
2021-09-14 20:00 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-03-05 10:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48396
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=56468
Summary|Undeclared library types |std::type_info is
|accepted in namespace std |implicitly declared
Last reconfirmed|2012-04-12 00:00:00 |2021-3-5
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Adjusting the summary because this is specific to std::type_info, it doesn't
happen for other types.
I think there's some historical reason that G++ pre-defines std::type_info, but
maybe we could make that only valid in system headers. It still causes bugs
even then, because libstdc++ can accidentally rely on the G++ behaviour, which
doesn't work with other compilers (e.g PR 56468).
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/48396] std::type_info is implicitly declared
2011-03-31 23:33 [Bug c++/48396] New: Undeclared library types accepted in namespace std paolo.carlini at oracle dot com
2012-04-12 12:25 ` [Bug c++/48396] " redi at gcc dot gnu.org
2021-03-05 10:09 ` [Bug c++/48396] std::type_info is implicitly declared redi at gcc dot gnu.org
@ 2021-09-14 20:00 ` redi at gcc dot gnu.org
2021-09-14 20:05 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-09-14 20:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48396
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2021-03-05 00:00:00 |2021-9-14
Keywords| |rejects-valid
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This breaks modules, and makes it very difficult to export a 'std' module, as
proposed by https://wg21.link/p2412r0
export module std;
// define it
namespace std
{
class type_info;
}
// exports
export namespace std { };
namespace std
{
export class type_info;
}
g++ -fmodules-ts -fmodule-only std.cc
std.cc:6:9: error: cannot declare 'struct std::type_info' in a different module
6 | class type_info;
| ^~~~~~~~~
<built-in>: note: declared here
std.cc:14:16: error: cannot declare 'struct std::type_info' in a different
module
14 | export class type_info;
| ^~~~~~~~~
<built-in>: note: declared here
std.cc:1:8: warning: not writing module 'std' due to errors
1 | export module std;
| ^~~~~~
As a stop-gap, could we maybe suppress the implicit definition when
-fmodules-ts is in use? Otherwise I am unable to prototype the proposal.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/48396] std::type_info is implicitly declared
2011-03-31 23:33 [Bug c++/48396] New: Undeclared library types accepted in namespace std paolo.carlini at oracle dot com
` (2 preceding siblings ...)
2021-09-14 20:00 ` redi at gcc dot gnu.org
@ 2021-09-14 20:05 ` redi at gcc dot gnu.org
2021-09-14 20:49 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-09-14 20:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48396
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
cp/rtti.c defines:
/* Declare language defined type_info type and a pointer to const
type_info. This is incomplete here, and will be completed when
the user #includes <typeinfo>. There are language defined
restrictions on what can be done until that is included. Create
the internal versions of the ABI types. */
void
init_rtti_processing (void)
{
push_nested_namespace (std_node);
tree type_info_type = xref_tag (class_type, get_identifier ("type_info"));
pop_nested_namespace (std_node);
const_type_info_type_node
= cp_build_qualified_type (type_info_type, TYPE_QUAL_CONST);
type_info_ptr_type = build_pointer_type (const_type_info_type_node);
vec_alloc (unemitted_tinfo_decls, 124);
create_tinfo_types ();
}
Is there a way to do that without making it visible to user code? Or without
implicitly adding it to the GMF?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/48396] std::type_info is implicitly declared
2011-03-31 23:33 [Bug c++/48396] New: Undeclared library types accepted in namespace std paolo.carlini at oracle dot com
` (3 preceding siblings ...)
2021-09-14 20:05 ` redi at gcc dot gnu.org
@ 2021-09-14 20:49 ` jason at gcc dot gnu.org
2021-09-15 4:27 ` cvs-commit at gcc dot gnu.org
2021-09-15 4:28 ` jason at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2021-09-14 20:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48396
--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Created attachment 51462
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51462&action=edit
patch to allow redeclaration in module
This isn't a proper fix, but may let you make progress with modularization.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/48396] std::type_info is implicitly declared
2011-03-31 23:33 [Bug c++/48396] New: Undeclared library types accepted in namespace std paolo.carlini at oracle dot com
` (4 preceding siblings ...)
2021-09-14 20:49 ` jason at gcc dot gnu.org
@ 2021-09-15 4:27 ` cvs-commit at gcc dot gnu.org
2021-09-15 4:28 ` jason at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-09-15 4:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48396
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:a53781c8fd258608780821168a7f5faf7be63690
commit r12-3538-ga53781c8fd258608780821168a7f5faf7be63690
Author: Jason Merrill <jason@redhat.com>
Date: Tue Sep 14 17:37:27 2021 -0400
c++: don't predeclare std::type_info [PR48396]
We've always predeclared std::type_info, which has been wrong for a while,
but now with modules it becomes more of a practical problem, if we want to
declare it in the purview of a module. So don't predeclare it. For
building up the type_info information to write out with the vtable, we can
use void* instead of type_info*, since they already aren't the real types.
PR c++/48396
gcc/cp/ChangeLog:
* cp-tree.h (enum cp_tree_index): Remove CPTI_TYPE_INFO_PTR_TYPE.
(type_info_ptr_type): Remove.
* rtti.c (init_rtti_processing): Don't predeclare std::type_info.
(typeid_ok_p): Check for null const_type_info_type_node.
(type_info_ptr_type, get_void_tinfo_ptr): New fns.
(get_tinfo_decl_dynamic, get_tinfo_ptr): Use them.
(ptr_initializer, ptm_initializer, get_pseudo_ti_init): Use them.
(get_tinfo_desc): Use const_ptr_type_node.
gcc/testsuite/ChangeLog:
* g++.dg/rtti/undeclared1.C: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/48396] std::type_info is implicitly declared
2011-03-31 23:33 [Bug c++/48396] New: Undeclared library types accepted in namespace std paolo.carlini at oracle dot com
` (5 preceding siblings ...)
2021-09-15 4:27 ` cvs-commit at gcc dot gnu.org
@ 2021-09-15 4:28 ` jason at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2021-09-15 4:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48396
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.0
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 8+ messages in thread