[Bug c++/67762] [C++1z] 'not a constant expression" errors only with -fsanitize=undefined

2022-12-31 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67762

Andrew Pinski  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #9 from Andrew Pinski  ---
Even though PR 71962 is reported after this bug, the comments has more analysis
of what is going on so closing as a dup.

*** This bug has been marked as a duplicate of bug 71962 ***

[Bug c++/67762] [C++1z] 'not a constant expression" errors only with -fsanitize=undefined

2021-11-10 Thread curdeius at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67762

--- Comment #8 from Curdeius Curdeius  ---
A different (rather small) reproduce.
https://godbolt.org/z/bz9sTd34o

It fails with all the versions of gcc from at least 7 (the above code needs
`auto` in template non-type parameter) to trunk from 2021-11-10.

Hope it helps!

```
#include 

#include 
#include 

namespace detail {

static inline void validate(date::weekday v) noexcept {
(void)v;
assert(v.ok());
}

template 
struct date_interval {
using duration_type = Duration;

duration_type begin{InitValue};

[[nodiscard]] constexpr auto begin_value() const noexcept {
if constexpr (GetValue != nullptr) {
return std::invoke(GetValue, begin);
} else {
return begin;
}
}
};

}  // namespace detail

using days_interval = detail::date_interval;

int main() {
days_interval days;
return (int)days.begin_value();
}
```

[Bug c++/67762] [C++1z] 'not a constant expression" errors only with -fsanitize=undefined

2021-04-27 Thread dushistov at mail dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67762

--- Comment #7 from Evgeniy Dushistov  ---
Here simple example extracted from Qt 6 git:

```
template
struct Prop {
void notify()
{
if constexpr (Signal != nullptr) {
}
}
};

class QObjectPrivate {
public:
struct ExtraData
{
inline void nameChangedForwarder()  {}
};
};

int main()
{
Prop<&QObjectPrivate::ExtraData::nameChangedForwarder>  prop;
prop.notify();
}

```

"g++ -std=c++17" compiles it just fine,
while "g++ -std=c++17 -fsanitize=undefined" gitves such error:

test2.cpp: In instantiation of 'void Prop::notify() [with auto Signal =
&QObjectPrivate::ExtraData::nameChangedForwarder]':
test2.cpp:21:13:   required from here
test2.cpp:5:34: error: '(QObjectPrivate::ExtraData::nameChangedForwarder != 0)'
is not a constant expression
5 | if constexpr (Signal != nullptr) {
  |   ~~~^~


This is with gcc 11.1.0

[Bug c++/67762] [C++1z] 'not a constant expression" errors only with -fsanitize=undefined

2015-09-29 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67762

Markus Trippelsdorf  changed:

   What|Removed |Added

  Attachment #36417|0   |1
is obsolete||

--- Comment #6 from Markus Trippelsdorf  ---
Created attachment 36418
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36418&action=edit
Somewhat reduced testcase


[Bug c++/67762] [C++1z] 'not a constant expression" errors only with -fsanitize=undefined

2015-09-29 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67762

Markus Trippelsdorf  changed:

   What|Removed |Added

  Attachment #36415|0   |1
is obsolete||

--- Comment #5 from Markus Trippelsdorf  ---
Created attachment 36417
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36417&action=edit
Somewhat reduced testcase

C-Reduce 2.4.0 was released yesterday, which doesn't crash anymore.
Somewhat reduced testcase attached.


[Bug c++/67762] [C++1z] 'not a constant expression" errors only with -fsanitize=undefined

2015-09-29 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67762

--- Comment #4 from Markus Trippelsdorf  ---
(In reply to Marek Polacek from comment #3)
> Not reducing anymore; creduce dies for me :(.

Yes, I was unsuccessful in reducing it with creduce, too.
(Well, clang doesn't support C++ concepts yet, so perhaps it is not
too surprising.)


[Bug c++/67762] [C++1z] 'not a constant expression" errors only with -fsanitize=undefined

2015-09-29 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67762

--- Comment #3 from Marek Polacek  ---
Not reducing anymore; creduce dies for me :(.


[Bug c++/67762] [C++1z] 'not a constant expression" errors only with -fsanitize=undefined

2015-09-29 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67762

--- Comment #2 from Marek Polacek  ---
The compile-time error goes away when adding
-fno-sanitize=null,returns-nonnull-attribute,nonnull-attribute to the
command-line options.


[Bug c++/67762] [C++1z] 'not a constant expression" errors only with -fsanitize=undefined

2015-09-29 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67762

Marek Polacek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2015-09-29
 Ever confirmed|0   |1

--- Comment #1 from Marek Polacek  ---
Confirmed.  I'll reduce this to something more usable.

Note that I get ICE with gcc-5:

In file included from /var/tmp/cmcstl2/include/stl2/type_traits.hpp:16:0,
 from /var/tmp/cmcstl2/test/variant.cpp:15:
/var/tmp/cmcstl2/include/stl2/detail/fwd.hpp:47:5: error: ‘requires’ does not
name a type
In file included from /var/tmp/cmcstl2/include/stl2/type_traits.hpp:18:0,
 from /var/tmp/cmcstl2/test/variant.cpp:15:
/var/tmp/cmcstl2/include/stl2/detail/concepts/core.hpp:24:3: error: ‘concept’
does not name a type
/var/tmp/cmcstl2/include/stl2/detail/concepts/core.hpp:27:3: error: ‘concept’
does not name a type
/var/tmp/cmcstl2/include/stl2/detail/concepts/core.hpp:30:3: error: ‘concept’
does not name a type
/var/tmp/cmcstl2/include/stl2/detail/concepts/core.hpp:33:3: error: ‘concept’
does not name a type
/var/tmp/cmcstl2/include/stl2/detail/concepts/core.hpp:42:5: error: ‘concept’
does not name a type
/var/tmp/cmcstl2/include/stl2/detail/concepts/core.hpp:55:32: error:
‘std::experimental::ranges_v1::detail::_Same’ has not been declared
/var/tmp/cmcstl2/include/stl2/detail/concepts/core.hpp:55:37: error: expected
‘>’ before ‘<’ token
/var/tmp/cmcstl2/include/stl2/detail/concepts/core.hpp:56:28: error: ‘Rest’ was
not declared in this scope
/var/tmp/cmcstl2/include/stl2/detail/concepts/core.hpp:56:32: error: expected
parameter pack before ‘...’
/var/tmp/cmcstl2/include/stl2/detail/concepts/core.hpp:56:20: error: template
argument 2 is invalid
/var/tmp/cmcstl2/include/stl2/detail/concepts/core.hpp:56:20: internal compiler
error: tree check: expected tree_vec, have error_mark in
get_innermost_template_args, at cp/pt.c:595
0xf2bdac tree_check_failed(tree_node const*, char const*, int, char const*,
...)
/home/marek/src/gcc/gcc/tree.c:9297
0x652619 tree_check(tree_node*, char const*, int, char const*, tree_code)
/home/marek/src/gcc/gcc/tree.h:2851
0x652619 get_innermost_template_args(tree_node*, int)
/home/marek/src/gcc/gcc/cp/pt.c:595
0x6a23e3 process_partial_specialization
/home/marek/src/gcc/gcc/cp/pt.c:4148
0x6a4467 push_template_decl_real(tree_node*, bool)
/home/marek/src/gcc/gcc/cp/pt.c:4907
0x640104 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
/home/marek/src/gcc/gcc/cp/decl.c:4839
0x735afd cp_parser_init_declarator
/home/marek/src/gcc/gcc/cp/parser.c:17195
0x736702 cp_parser_single_declaration
/home/marek/src/gcc/gcc/cp/parser.c:23850
0x7369b8 cp_parser_template_declaration_after_export
/home/marek/src/gcc/gcc/cp/parser.c:23641
0x73bf19 cp_parser_declaration
/home/marek/src/gcc/gcc/cp/parser.c:11343
0x73a41a cp_parser_declaration_seq_opt
/home/marek/src/gcc/gcc/cp/parser.c:11265
0x73ac95 cp_parser_namespace_body
/home/marek/src/gcc/gcc/cp/parser.c:16293
0x73ac95 cp_parser_namespace_definition
/home/marek/src/gcc/gcc/cp/parser.c:16274
0x73be79 cp_parser_declaration
/home/marek/src/gcc/gcc/cp/parser.c:11367
0x73a41a cp_parser_declaration_seq_opt
/home/marek/src/gcc/gcc/cp/parser.c:11265
0x73ac95 cp_parser_namespace_body
/home/marek/src/gcc/gcc/cp/parser.c:16293
0x73ac95 cp_parser_namespace_definition
/home/marek/src/gcc/gcc/cp/parser.c:16274
0x73be79 cp_parser_declaration
/home/marek/src/gcc/gcc/cp/parser.c:11367
0x73a41a cp_parser_declaration_seq_opt
/home/marek/src/gcc/gcc/cp/parser.c:11265
0x73ac95 cp_parser_namespace_body
/home/marek/src/gcc/gcc/cp/parser.c:16293
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.