Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/il.c
Original file line number Diff line number Diff line change
Expand Up @@ -8665,19 +8665,22 @@ are done.
} /* if */
if (!identical_types_full(node1->type, node2->type, itf_options)) {
eq = FALSE;
} else if ((options & CC_EXACT_EQUIVALENCE) &&
(node1->extra.rescan_info != NULL) !=
(node2->extra.rescan_info != NULL)) {
/* The two expressions are equivalent, but one has associated rescan
information and the other not. With the given option, the two
should not be considered equivalent because it could cause the
version with rescan information to be replaced by the other version,
thereby causing spurious rescan failures. (If the two nodes have
associated rescan information, that information can be assumed to
be equivalent since the expressions are equivalent.) */
eq = FALSE;
} /* if */
} /* if */
if (eq && (options & CC_EXACT_EQUIVALENCE) &&
(node1->extra.rescan_info != NULL) !=
(node2->extra.rescan_info != NULL)) {
/* The two expressions are equivalent, but one has associated rescan
information and the other not. With the given option, the two
should not be considered equivalent because it could cause the
version with rescan information to be replaced by the other version,
thereby causing spurious rescan failures. (If the two nodes have
associated rescan information, that information can be assumed to
be equivalent since the expressions are equivalent.) This check is
done even when the type comparison is skipped (e.g., for variable
references). */
eq = FALSE;
} /* if */
} /* if */
done:
#if DEBUG
Expand Down
17 changes: 17 additions & 0 deletions src/pending_changes/ctad-missing-rescan-info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[GH #335]
Fix CTAD rescan info for reused specializations

An internal error ("missing default rescan info") could occur when building
an implicit deduction guide for a constructor whose parameter type is a
class template specialization with a nontype template argument referring to
a dependent static data member, if that same specialization was already used
earlier in the class (e.g., in a member declaration). For example, with
--c++17:

template<int> struct P {};
template<typename T> struct A {
static constexpr bool b = sizeof(T) == 1;
P<b> m;
A(T, P<b>);
};
void g() { A{char{}, {}}; } // Previously caused an internal error.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fe_only -DTEST_NUMBER=1 --c++17 Test_name.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//type:fp
//options_all:--c++17

// A class template specialization whose nontype template argument refers to
// a dependent static data member (P<b> below) was first created by a member
// declaration and later reused for the same specialization in a constructor
// parameter type. The first argument expression lacked the information
// needed to redo semantic analysis, so building the implicit deduction guide
// for class template argument deduction caused an internal error ("missing
// default rescan info").

template<typename, typename> constexpr bool f() { return true; }

template<int> struct P {};

template<typename T> struct A {
static constexpr bool b = f<T, char>();
P<b> m;
A(T, P<b>);
};

template<typename T> struct B {
static constexpr bool b = sizeof(T) == 1;
P<b> m;
B(T, P<b>);
};

void g() {
A{char{}, {}};
B{char{}, {}};
}
Loading