Comments (8)
thanks :) marking this as a good first PR because it's a really silly mistake on my part. the fix is quite easy I think.
this is the offending code:tl::optional<NodeId> resolved = tl::nullopt; auto label = ctx.labels.get (expr.get_ident ()); auto value = ctx.values.get (expr.get_ident ()); if (label) resolved = label; else if (value) resolved = value; // TODO: else emit error? ctx.map_usage (expr.get_node_id (), *resolved);which is indeed problematic, because if neither
label
norvalue
are valid resolution IDs, then we are accessing a nullopt's value. it's not dangerous or anything, an assertion will pop, but it will indeed be uninitialized I believe.
the correct fix would be to only callmap_usage
ifresolved
is a valid value - otherwise, emit an error or at least crash. which hopefully should get rid of the warningwith which function should we look into to emit an error for cause a crash. Can you also point me to the code piece you've shown? Thank you!
this particular piece of code is in gcc/rust/resolve/rust-late-name-resolver-2.0.cc
around line 125, in the function void Late::visit (AST::IdentifierExpr &expr)
for emitting an error, you can look at using rust_error_at
- there are a lot of examples in the rest of the codebase.
the error emission should look something like this:
rust_error_at(expr.get_locus (), "could not resolve identifier expression: %qs", expr.get_ident ().as_string ().c_str ());
from gccrs.
thanks :) marking this as a good first PR because it's a really silly mistake on my part. the fix is quite easy I think.
this is the offending code:
tl::optional<NodeId> resolved = tl::nullopt;
auto label = ctx.labels.get (expr.get_ident ());
auto value = ctx.values.get (expr.get_ident ());
if (label)
resolved = label;
else if (value)
resolved = value;
// TODO: else emit error?
ctx.map_usage (expr.get_node_id (), *resolved);
which is indeed problematic, because if neither label
nor value
are valid resolution IDs, then we are accessing a nullopt's value. it's not dangerous or anything, an assertion will pop, but it will indeed be uninitialized I believe.
the correct fix would be to only call map_usage
if resolved
is a valid value - otherwise, emit an error or at least crash. which hopefully should get rid of the warning
from gccrs.
thanks :) marking this as a good first PR because it's a really silly mistake on my part. the fix is quite easy I think.
this is the offending code:
tl::optional<NodeId> resolved = tl::nullopt; auto label = ctx.labels.get (expr.get_ident ()); auto value = ctx.values.get (expr.get_ident ()); if (label) resolved = label; else if (value) resolved = value; // TODO: else emit error? ctx.map_usage (expr.get_node_id (), *resolved);which is indeed problematic, because if neither
label
norvalue
are valid resolution IDs, then we are accessing a nullopt's value. it's not dangerous or anything, an assertion will pop, but it will indeed be uninitialized I believe.the correct fix would be to only call
map_usage
ifresolved
is a valid value - otherwise, emit an error or at least crash. which hopefully should get rid of the warning
with which function should we look into to emit an error for cause a crash. Can you also point me to the code piece you've shown? Thank you!
from gccrs.
should I assign you the issue @badumbatish? I think it will require building g++
from the commit @jbglaw mentioned and using this to build gccrs in order to ensure it's resolved
from gccrs.
Just needs to be a "fairly recent" GCC, from the past few days. I'd also offer to test patches by running them through my CI pipeline with --enable-werror-always
.
from gccrs.
should I assign you the issue @badumbatish? I think it will require building
g++
from the commit @jbglaw mentioned and using this to build gccrs in order to ensure it's resolved
oops i didn't see this. Yes i'll try on this issue
from gccrs.
thanks :) marking this as a good first PR because it's a really silly mistake on my part. the fix is quite easy I think.
this is the offending code:tl::optional<NodeId> resolved = tl::nullopt; auto label = ctx.labels.get (expr.get_ident ()); auto value = ctx.values.get (expr.get_ident ()); if (label) resolved = label; else if (value) resolved = value; // TODO: else emit error? ctx.map_usage (expr.get_node_id (), *resolved);which is indeed problematic, because if neither
label
norvalue
are valid resolution IDs, then we are accessing a nullopt's value. it's not dangerous or anything, an assertion will pop, but it will indeed be uninitialized I believe.
the correct fix would be to only callmap_usage
ifresolved
is a valid value - otherwise, emit an error or at least crash. which hopefully should get rid of the warningwith which function should we look into to emit an error for cause a crash. Can you also point me to the code piece you've shown? Thank you!
this particular piece of code is in
gcc/rust/resolve/rust-late-name-resolver-2.0.cc
around line 125, in the functionvoid Late::visit (AST::IdentifierExpr &expr)
for emitting an error, you can look at using
rust_error_at
- there are a lot of examples in the rest of the codebase.the error emission should look something like this:
rust_error_at(expr.get_locus (), "could not resolve identifier expression: %qs", expr.get_ident ().as_string ().c_str ());
I just realized the make error output shows the file crash location ....
from gccrs.
Related Issues (20)
- Add documentation around common git operations for the project
- Create issues and testcases for RfL proc macros HOT 2
- Split up `rust-macro-builtins.cc` HOT 1
- Create `FormatArgs` AST node HOT 3
- `AST::LiteralExpr` should differentiate between strings and raw strings HOT 1
- `testsuite/execute/torture/issue-2187.rs` has the wrong ending pattern and fails to show second print
- Ensure standalone `format_args!()` invocations get lowered properly HOT 4
- Unused format arguments are hard errors
- Function pointers are not getting monormophized fully HOT 1
- Cleanup `BiMap` class HOT 1
- Add checking that `cargo` exists when building gccrs HOT 3
- Locally provide crates that `libgrust` depends on HOT 1
- Move `cargo build` into the GCC build directory HOT 3
- Unused parentheses in parameters causes internal compiler error
- borrowck: Implement method translation to BIR HOT 2
- Don't hard-code `-ldl -lpthread` for `format_args` HOT 2
- Allow visibility modifiers for extern types HOT 4
- `cargo` should build for the host system
- Pass configuration flags to `cargo` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gccrs.