[Bug c++/55962] improper location for static_assert
manu at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jan 13 19:17:00 GMT 2013
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.
More information about the Gcc-bugs
mailing list