public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/55962] improper location for static_assert
Date: Sun, 13 Jan 2013 19:17:00 -0000	[thread overview]
Message-ID: <bug-55962-4-Z6JmMW6z6r@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55962-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55962

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-01-13
                 CC|                            |manu at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2013-01-13 19:17:05 UTC ---
Confirmed. If you run GCC under GDB, you'll notice that the call 

  if (expr == error_mark_node || TREE_CODE (expr) == TREE_LIST)
    {
      if (complain & tf_error)
        qualified_name_lookup_error (scope,
                                     TREE_OPERAND (qualified_id, 1),
=>                                   expr, input_location);
      return error_mark_node;
    }


uses input_location. I think it should use an explicit location. The problem is
how to get the location of 'value' to this point. 

Up one-level input_location is "hacked" to be 

 loc = input_location;
  if (EXPR_HAS_LOCATION (t))
    input_location = EXPR_LOCATION (t);

but in this case t is just:

 <scope_ref 0x7ffff753e640 tree_0
    arg 0 <template_type_parm 0x7ffff75439d8 T type_0 type_6 VOID
        align 8 symtab 0 alias set -1 canonical type 0x7ffff75439d8
       index 0 level 1 orig_level 1
        chain <type_decl 0x7ffff753f958 T>>
    arg 1 <identifier_node 0x7ffff7552d10 value
        bindings <(nil)>
        local bindings <(nil)>>>

so it doesn't have a location, so it uses input_location.

The issue seems to be that input_location has somehow been smashed by something
else. For the testcase:

void assert(int, const char *);
template <typename T>
int
foo(int b)
{
  assert(T::value, "toto");
  return b;
}

int
main()
{
  foo<int>(12);
}


we get:

test.cc:6:26: error: ‘value’ is not a member of ‘int’
   assert(T::value, "toto");
                          ^
which is slightly better and the only difference seems to be the value of
input_location in the condition above.

This requires much more investigation.


  reply	other threads:[~2013-01-13 19:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-13 17:22 [Bug c++/55962] New: " akim.demaille at gmail dot com
2013-01-13 19:17 ` manu at gcc dot gnu.org [this message]
2021-08-02  0:24 ` [Bug c++/55962] " pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-55962-4-Z6JmMW6z6r@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).