* [Bug c++/115960] gcc throws an error when I use Optional in c++17.
2024-07-16 21:39 [Bug c++/115960] New: gcc throws an error when I use Optional in c++17 noahmartinwilliams at gmail dot com
@ 2024-07-16 21:59 ` pinskia at gcc dot gnu.org
2024-07-16 22:14 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-07-16 21:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115960
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
llvm/include/llvm/ADT/Optional.h is not included so llvm::Optional is not
declared anywhere.
GCC's error message is correct.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/115960] gcc throws an error when I use Optional in c++17.
2024-07-16 21:39 [Bug c++/115960] New: gcc throws an error when I use Optional in c++17 noahmartinwilliams at gmail dot com
2024-07-16 21:59 ` [Bug c++/115960] " pinskia at gcc dot gnu.org
@ 2024-07-16 22:14 ` pinskia at gcc dot gnu.org
2024-07-16 22:39 ` noahmartinwilliams at gmail dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-07-16 22:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115960
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Anyways this is not a GCC issue.
The AttrBuilder::addAllocSizeAttr is declared in the preprocessed source as:
AttrBuilder &addAllocSizeAttr(unsigned ElemSizeArg,
const std::optional<unsigned> &NumElemsArg);
But the upstream is defined as:
AttrBuilder &addAllocSizeAttr(unsigned ElemSizeArg,
const Optional<unsigned> &NumElemsArg);
https://github.com/hdoc/llvm-project/blob/a38b25fa77bdf1437c690494ae6d61179b3bb4f8/llvm/include/llvm/IR/Attributes.h#L1188
Also note
https://github.com/llvm/llvm-project/commit/125f4457a54a550846732763ee36b1447ec8d66e
Anyways this still not a GCC bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/115960] gcc throws an error when I use Optional in c++17.
2024-07-16 21:39 [Bug c++/115960] New: gcc throws an error when I use Optional in c++17 noahmartinwilliams at gmail dot com
2024-07-16 21:59 ` [Bug c++/115960] " pinskia at gcc dot gnu.org
2024-07-16 22:14 ` pinskia at gcc dot gnu.org
@ 2024-07-16 22:39 ` noahmartinwilliams at gmail dot com
2024-07-17 9:15 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: noahmartinwilliams at gmail dot com @ 2024-07-16 22:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115960
--- Comment #3 from Noah Williams <noahmartinwilliams at gmail dot com> ---
(In reply to Andrew Pinski from comment #2)
> Anyways this is not a GCC issue.
>
> The AttrBuilder::addAllocSizeAttr is declared in the preprocessed source
> as:
> AttrBuilder &addAllocSizeAttr(unsigned ElemSizeArg,
> const std::optional<unsigned> &NumElemsArg);
>
> But the upstream is defined as:
>
> AttrBuilder &addAllocSizeAttr(unsigned ElemSizeArg,
> const Optional<unsigned> &NumElemsArg);
>
>
> https://github.com/hdoc/llvm-project/blob/
> a38b25fa77bdf1437c690494ae6d61179b3bb4f8/llvm/include/llvm/IR/Attributes.
> h#L1188
>
>
> Also note
> https://github.com/llvm/llvm-project/commit/
> 125f4457a54a550846732763ee36b1447ec8d66e
>
>
> Anyways this still not a GCC bug.
Darn. I was hoping this was a gcc bug since that would make fixing the llvm-hs
project easier. :(
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/115960] gcc throws an error when I use Optional in c++17.
2024-07-16 21:39 [Bug c++/115960] New: gcc throws an error when I use Optional in c++17 noahmartinwilliams at gmail dot com
` (2 preceding siblings ...)
2024-07-16 22:39 ` noahmartinwilliams at gmail dot com
@ 2024-07-17 9:15 ` redi at gcc dot gnu.org
2024-07-17 18:43 ` noahmartinwilliams at gmail dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2024-07-17 9:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115960
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> The problem seems to be that, despite passing "-std=c++17", it doesn't use c++17
> header files for the Optional identifier.
Why should it? The name "Optional" is not part of any C++ standard.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/115960] gcc throws an error when I use Optional in c++17.
2024-07-16 21:39 [Bug c++/115960] New: gcc throws an error when I use Optional in c++17 noahmartinwilliams at gmail dot com
` (3 preceding siblings ...)
2024-07-17 9:15 ` redi at gcc dot gnu.org
@ 2024-07-17 18:43 ` noahmartinwilliams at gmail dot com
2024-07-17 18:46 ` pinskia at gcc dot gnu.org
2024-07-18 11:25 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: noahmartinwilliams at gmail dot com @ 2024-07-17 18:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115960
--- Comment #5 from Noah Williams <noahmartinwilliams at gmail dot com> ---
(In reply to Jonathan Wakely from comment #4)
> > The problem seems to be that, despite passing "-std=c++17", it doesn't use c++17
> > header files for the Optional identifier.
>
> Why should it? The name "Optional" is not part of any C++ standard.
It isn't? The library I was trying to compile included the "optional" header,
and I had looked it up and found it was part of C++ 17, so I thought it was
part of the standard.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/115960] gcc throws an error when I use Optional in c++17.
2024-07-16 21:39 [Bug c++/115960] New: gcc throws an error when I use Optional in c++17 noahmartinwilliams at gmail dot com
` (4 preceding siblings ...)
2024-07-17 18:43 ` noahmartinwilliams at gmail dot com
@ 2024-07-17 18:46 ` pinskia at gcc dot gnu.org
2024-07-18 11:25 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-07-17 18:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115960
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Noah Williams from comment #5)
> It isn't? The library I was trying to compile included the "optional"
> header, and I had looked it up and found it was part of C++ 17, so I thought
> it was part of the standard.
std::optional is part of C++17 but Optional is not.
LLVM had its own Optional class which basically implemented what was included
in C++17 before they wrote LLVM in C++17. This is the whole confusing thing
with their code is that LLVM is compiled as C++17 but sometimes uses their own
Optional class and sometimes std::optional. But again this is not GCC related
issue and should be discussed in LLVM's developmental forms instead.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/115960] gcc throws an error when I use Optional in c++17.
2024-07-16 21:39 [Bug c++/115960] New: gcc throws an error when I use Optional in c++17 noahmartinwilliams at gmail dot com
` (5 preceding siblings ...)
2024-07-17 18:46 ` pinskia at gcc dot gnu.org
@ 2024-07-18 11:25 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2024-07-18 11:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115960
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #6)
> (In reply to Noah Williams from comment #5)
> > It isn't? The library I was trying to compile included the "optional"
> > header, and I had looked it up and found it was part of C++ 17, so I thought
> > it was part of the standard.
>
> std::optional is part of C++17 but Optional is not.
And names in C++ are case sensitive. optional != Optional.
^ permalink raw reply [flat|nested] 8+ messages in thread