Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <v3t6ru$1jpih$2@dont-email.me>
Deutsch   English   Français   Italiano  
<v3t6ru$1jpih$2@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Thiago Adams <thiago.adams@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: dbg_break macro
Date: Thu, 6 Jun 2024 17:40:30 -0300
Organization: A noiseless patient Spider
Lines: 77
Message-ID: <v3t6ru$1jpih$2@dont-email.me>
References: <v3ptto$vgqm$1@dont-email.me>
 <pan$c5a7f$519c50bb$a44bc8ca$b7510c5d@invalid.invalid>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 06 Jun 2024 22:40:30 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="629b39aac51adf13d22ab925c2f31a10";
	logging-data="1697361"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18s5UGyRKUi994CxJFYXMdSKIVr5DgMha0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:AsUwCftqyAcG/lEO8Ihitc9CW5w=
Content-Language: en-US
In-Reply-To: <pan$c5a7f$519c50bb$a44bc8ca$b7510c5d@invalid.invalid>
Bytes: 2802

On 06/06/2024 17:10, Blue-Maned_Hawk wrote:
> 
> I feel like you would probably want to be using a debugger to set your
> breakpoints, although the Clang dialect of C does have a
> __builtin_debugtrap builtin subroutine.
> 
> 
> 


C++ 26 will have breakpoint. Lot of links about how to do that.
https://en.cppreference.com/w/cpp/utility/breakpoint

But, thinking about my usage, the source line, message, etc., everything 
that assert has is useful. What is not useful is to pass a constant 
expression for something that is supposed to be a runtime check.

I remember when I thought that static_assert could just be assert 
because it is not hard for the compiler to know when we have a constant 
expression or not. If we have a constant expression, this should be just 
like static_assert.

assert(2 == 2); // compile-time check

If the expression is not constant, then it would be checked at runtime 
during debugging.

This idea fails fast, when we think assert is used with assert(0);

This code would not compile.

if (condition)
{
   ///
}
else{
   assert(0);
   return -1;
}


So, my idea with dbg_break is to reserve assert for what it does better, 
that is runtime checks.

Another sample

int f(int v){
  switch(v)
  {
     case 1:break;
     case 2:break;
     default:
      assert(0);
      break;
  }
}

This code does not have a plan B in case default is reached.

But this one have.

int f(int v){
  switch(v)
  {
     case 1:break;
     case 2:break;
     default:
       dbg_break("missing case ?");
      break;
  }
  return -1;
}

I think dbg_break also transmit the idea that the branch is possible 
while assert(0) can be confusing.