191 questions
4
votes
2
answers
323
views
std::unreachable not compiling only under MSVC
The following snippet of code compiles fine using gcc and clang with -std=c++23 -Wall and -Werror, but fails to compile under msvc with /std:c++latest /W4 /WX (Demo).
#include <utility>
bool ...
1
vote
2
answers
531
views
Emitting a message when reaching std::unreachable() in Release builds
I know when you type std::unreachable() in your code you are guaranteeing that the code will never reach that point, and if it does it's UB (anything goes). In debug builds I've noticed there's an ...
2
votes
1
answer
232
views
Function can't be called after std::unreachable if object constructed on stack?
Normally, I can place function calls after std::unreachable, and it has no effect. This works on MSVC, Clang, and GCC, except with GCC there is an extra detail that makes it fail compilation:
#include ...
-3
votes
1
answer
89
views
Is throw reachable after return statement in using context? [duplicate]
Is this throw statement even reachable?
It's not showing as unreachable by compiler.
public static async Task<List<string>> GetSomething(int id)
{
using (DbContext context = new ...
0
votes
0
answers
65
views
How to prevent Vue extension from "fixing" my code?
I'm experiencing an issue where "unreachable code" in a Vue/TypeScript file is automatically deleted on save. (A pretty shocking behaviour, often I'm temporarily adding a "return false&...
0
votes
1
answer
41
views
Unreacheable code in Java/SpringBoot Application when using mongoTemplate
public PsaDTO save(PsaDTO psaDTO) {
Query query = new Query(Criteria.where("numPratica").is(psaDTO.getNumPratica()));
myLogger.info(myLogger.msgBuilder(MyLogger.SELECT_ID, ...
0
votes
1
answer
467
views
Incorrect warning C4702: unreachable code?
I am currently working on the following function:
int cuda_device_count = 0;
bool cuda_enabled = true;
char devname[256];
// logger_spd is an spdlog::logger with file sink
...
void InitCuda()
{
/...
1
vote
2
answers
2k
views
What should happen when control reaches __builtin_unreachable?
I wrote this code:
enum Color
{
kRed,
kGreen,
kBlue,
kUnexistingColor
};
const char* foo(Color color)
{
switch (color)
{
case kRed:
return "red";
...
1
vote
2
answers
485
views
How to visit on multiple variants with restricted to same type
I have a question about using a generic visitor with exclusion of non-equal types. Suppose I have the following:
using StorageT = std::variant<std::vector<int>, std::vector<double>>;
...
1
vote
1
answer
413
views
Check for unreachable at compilation time in Rust
I have enum consisting of a few variants:
enum Foo {
A,
B,
C,
}
and i have a function, that has loop with if and match inside, all branches of which is diverging:
fn my_function() -> i32 {
...
0
votes
1
answer
217
views
How to calculate a post dominator tree in LLVM excluding some basic blocks?
I built a post dominator tree for a function in my LLVM pass. However, the function has several blocks containing only unreachable instructions, which causes that the return block cannot post-dominate ...
0
votes
1
answer
54
views
Code is unreachable but I have no return function
This is my first post so I am sorry if I make any mistakes writing this. So I'm making a calculator program as my first personal program after learning enough on how to code with python. But I ran ...
1
vote
1
answer
225
views
Unreachable case except for null in scala
I have the following helper function. I am trying to create a word frequency List. (a,b,a) => [(a,2),(b,1)]:
def add_to_lop(c:Char, lop: List[(Char, Int)]):List[(Char, Int)] = {
lop match {
...
0
votes
1
answer
1k
views
"This code is unreachable" warning in pycharm
The following part of my code is highlighted as code unreachable in pycharm IDE.
for row in range(frame_height):
for col in range(frame_width):
if i < ...
3
votes
3
answers
403
views
Can the gnat compiler find unused specification procedures/functions/variables?
Is there a warning option switch that will identify spec-level procedures, functions, or variables that are not called or referenced anywhere? I've tried the switches below without luck.
This is what ...