public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111269] New: Confusing location of error in source code
@ 2023-09-01 13:24 alx at kernel dot org
  2023-09-01 16:55 ` [Bug c/111269] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: alx at kernel dot org @ 2023-09-01 13:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111269
           Summary: Confusing location of error in source code
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alx at kernel dot org
  Target Milestone: ---

I've been confused for some time with a compilation error that
pointed to a slightly-off location.  I wasn't seeing that I used
a temporary variable in a constant expression.  The code could be
reduced to:

$ cat const.c 
int
main(void)
{
        int x = 42;

        _Static_assert(0 || 7 > x, "");
}
$ gcc-13 -Wall -Wextra const.c
const.c: In function ‘main’:
const.c:6:26: error: expression in static assertion is not constant
    6 |         _Static_assert(0 || 7 > x, "");
      |                        ~~^~~~~~~~
$ clang-16 -Weverything const.c
const.c:6:26: error: static assertion expression is not an integral constant
expression
        _Static_assert(0 || 7 > x, "");
                       ~~~~~~~~~^
1 error generated.


Clang points to the precise location of the problem, while GCC is too fuzzy.

I suspect this is a duplicate of other bugs, but I'm not sure, so I'll let you
decide that.

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

end of thread, other threads:[~2023-09-02  0:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-01 13:24 [Bug c/111269] New: Confusing location of error in source code alx at kernel dot org
2023-09-01 16:55 ` [Bug c/111269] " pinskia at gcc dot gnu.org
2023-09-01 16:55 ` pinskia at gcc dot gnu.org
2023-09-02  0:29 ` [Bug c/111269] location for non-constant expressions inside static assert could be better alx at kernel dot org
2023-09-02  0:29 ` alx at kernel dot 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).