public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100482] New: namespaces as int in decltype expression
@ 2021-05-08  2:45 hahayes12 at tutanota dot com
  2021-05-08  3:31 ` [Bug c++/100482] " sand at rifkin dot dev
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: hahayes12 at tutanota dot com @ 2021-05-08  2:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100482

            Bug ID: 100482
           Summary: namespaces as int in decltype expression
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hahayes12 at tutanota dot com
  Target Milestone: ---

case:

#include <iostream>
int main() {
    decltype(std) i{1};
    std::cout << i;
}

g++ main.cpp

./a.out
1


as you can see namespaces are usable in decltype expressions and treated as
ints.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100482] namespaces as int in decltype expression
  2021-05-08  2:45 [Bug c++/100482] New: namespaces as int in decltype expression hahayes12 at tutanota dot com
@ 2021-05-08  3:31 ` sand at rifkin dot dev
  2021-05-08  8:00 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: sand at rifkin dot dev @ 2021-05-08  3:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100482

--- Comment #1 from Jeremy R. <sand at rifkin dot dev> ---
This appears to be valid for function return types as well but the compiler
does error when decltype is used in a function parameter

namespace std{}
int A(int a) { // fine
    decltype(std) b = a;
    return b;
}
decltype(std) B(int a) {  // fine
    decltype(std) b = a;
    return b;
}
auto C(int a) -> decltype(std) {  // fine
    decltype(std) b = a;
    return b;
}
int D(decltype(std) a) { // error: expected initializer before 'a'
    decltype(std) b = a;
    return b;
}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100482] namespaces as int in decltype expression
  2021-05-08  2:45 [Bug c++/100482] New: namespaces as int in decltype expression hahayes12 at tutanota dot com
  2021-05-08  3:31 ` [Bug c++/100482] " sand at rifkin dot dev
@ 2021-05-08  8:00 ` redi at gcc dot gnu.org
  2021-05-10  8:04 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-05-08  8:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100482

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-05-08
             Status|UNCONFIRMED                 |NEW

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100482] namespaces as int in decltype expression
  2021-05-08  2:45 [Bug c++/100482] New: namespaces as int in decltype expression hahayes12 at tutanota dot com
  2021-05-08  3:31 ` [Bug c++/100482] " sand at rifkin dot dev
  2021-05-08  8:00 ` redi at gcc dot gnu.org
@ 2021-05-10  8:04 ` rguenth at gcc dot gnu.org
  2023-08-08 20:03 ` cvs-commit at gcc dot gnu.org
  2024-04-05  6:48 ` nshead at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-10  8:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100482

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
*** Bug 100481 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100482] namespaces as int in decltype expression
  2021-05-08  2:45 [Bug c++/100482] New: namespaces as int in decltype expression hahayes12 at tutanota dot com
                   ` (2 preceding siblings ...)
  2021-05-10  8:04 ` rguenth at gcc dot gnu.org
@ 2023-08-08 20:03 ` cvs-commit at gcc dot gnu.org
  2024-04-05  6:48 ` nshead at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-08-08 20:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100482

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:a90bd3ea6d1ba27b15476f0a768d7952c6723420

commit r14-3087-ga90bd3ea6d1ba27b15476f0a768d7952c6723420
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date:   Tue Aug 8 12:48:43 2023 +1000

    c++: Report invalid id-expression in decltype [PR100482]

    This patch ensures that any errors raised by finish_id_expression when
    parsing a decltype expression are properly reported, rather than
    potentially going ignored and causing invalid code to be accepted.

    We can also now remove the separate check for templates without args as
    this is also checked for in finish_id_expression.

            PR c++/100482

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_decltype_expr): Report errors raised by
            finish_id_expression.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/decltype-100482.C: New test.

    Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100482] namespaces as int in decltype expression
  2021-05-08  2:45 [Bug c++/100482] New: namespaces as int in decltype expression hahayes12 at tutanota dot com
                   ` (3 preceding siblings ...)
  2023-08-08 20:03 ` cvs-commit at gcc dot gnu.org
@ 2024-04-05  6:48 ` nshead at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-04-05  6:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100482

Nathaniel Shead <nshead at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |nshead at gcc dot gnu.org
   Target Milestone|---                         |14.0
         Resolution|---                         |FIXED

--- Comment #4 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Fixed in GCC 14.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-05  6:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-08  2:45 [Bug c++/100482] New: namespaces as int in decltype expression hahayes12 at tutanota dot com
2021-05-08  3:31 ` [Bug c++/100482] " sand at rifkin dot dev
2021-05-08  8:00 ` redi at gcc dot gnu.org
2021-05-10  8:04 ` rguenth at gcc dot gnu.org
2023-08-08 20:03 ` cvs-commit at gcc dot gnu.org
2024-04-05  6:48 ` nshead 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).