public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110911] New: Confusing diagnostic on misplaced static_assert
@ 2023-08-05 7:45 pacoarjonilla at yahoo dot es
2023-08-05 13:26 ` [Bug c++/110911] " redi at gcc dot gnu.org
2023-08-05 13:31 ` redi at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: pacoarjonilla at yahoo dot es @ 2023-08-05 7:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110911
Bug ID: 110911
Summary: Confusing diagnostic on misplaced static_assert
Product: gcc
Version: og13 (devel/omp/gcc-13)
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pacoarjonilla at yahoo dot es
Target Milestone: ---
This code (note static_assert instead of static_cast)
#include <complex>
void f(float m)
{
std::complex<double> c = std::complex<double>(static_assert<double>(m),0);
}
generates the diagnostic
<source>: In function 'void f(float)':
<source>:4:50: error: expected primary-expression before '(' token
4 | std::complex<double> c =
std::complex<double>(static_assert<double>(m),0);
| ^
<source>:4:51: error: expected primary-expression before 'static_assert'
4 | std::complex<double> c =
std::complex<double>(static_assert<double>(m),0);
|
But the problem is not before the '(' token, nor before static_assert.
A suggestion such as "static_assert not valid here. Did you mean
'static_cast'?" would be nice.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/110911] Confusing diagnostic on misplaced static_assert
2023-08-05 7:45 [Bug c++/110911] New: Confusing diagnostic on misplaced static_assert pacoarjonilla at yahoo dot es
@ 2023-08-05 13:26 ` redi at gcc dot gnu.org
2023-08-05 13:31 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2023-08-05 13:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110911
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2023-08-05
Status|UNCONFIRMED |NEW
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think this would need a very specific custom diagnostic just for this case.
But I think I've made the same typo myself and I agree it would be nice, if
it's possible to do.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/110911] Confusing diagnostic on misplaced static_assert
2023-08-05 7:45 [Bug c++/110911] New: Confusing diagnostic on misplaced static_assert pacoarjonilla at yahoo dot es
2023-08-05 13:26 ` [Bug c++/110911] " redi at gcc dot gnu.org
@ 2023-08-05 13:31 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2023-08-05 13:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110911
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Although Dave Malcolm has recommended that we don't use "did you mean...?"
phrasing, but something like "static_assert not valid here, static_cast would
be valid".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-05 13:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-05 7:45 [Bug c++/110911] New: Confusing diagnostic on misplaced static_assert pacoarjonilla at yahoo dot es
2023-08-05 13:26 ` [Bug c++/110911] " redi at gcc dot gnu.org
2023-08-05 13:31 ` redi 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).