It looks like there may be another similar defect targeting gcc14.2 (Arch 
again). When recompiling a personal CLI tool that uses the 
[docopt](https://github.com/docopt/docopt.nim) library I am getting a similar 
error.

This can be reproduced by running the test suite for docopt 0.7.1: :
    
    
    $ git clone https://github.com/docopt/docopt.nim
    $ cd docopt
    $ git checkout v0.7.1
    $ nimble test
    <<<... snip ...>>>
    /home/jdb/projects/third-party/docopt.nim/src/docopt.nim: In function 
‘_ZN4test12single_matchE3refIN4test24ArgumentcolonObjectType_EE3seqI3refIN4test23PatterncolonObjectType_EEE’:
    /home/jdb/projects/third-party/docopt.nim/src/docopt.nim:238:263: error: 
assignment to ‘tyObject_PatterncolonObjectType___lXfbQ9c5hfGswttAihJ79c2w *’ 
from incompatible pointer type 
‘tyObject_ArgumentcolonObjectType___4WrxrWmB9aqSxzDk2md9cgPg *’ 
[-Wincompatible-pointer-types]
      238 |   raise new_exception(ValueError, "Not found")
          |                                                                     
                                                                                
                                                                                
                                  ^
    /home/jdb/projects/third-party/docopt.nim/src/docopt.nim: In function 
‘_ZN4test12single_matchE3refIN4test23CommandcolonObjectType_EE3seqI3refIN4test23PatterncolonObjectType_EEE’:
    /home/jdb/projects/third-party/docopt.nim/src/docopt.nim:247:460: error: 
assignment to ‘tyObject_PatterncolonObjectType___lXfbQ9c5hfGswttAihJ79c2w *’ 
from incompatible pointer type 
‘tyObject_CommandcolonObjectType___vPz31XMzxwUHxxGl9bp7J5Q *’ 
[-Wincompatible-pointer-types]
      247 |   raise new_exception(ValueError, "Not found")
          |                                                                     
                                                                                
                                                                                
                                                                                
                                                                                
                                                                       ^
    Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3 
-pthread -g3 -Og   -I/home/jdb/.asdf/installs/nim/2.0.8/lib 
-I/home/jdb/projects/third-party/docopt.nim/test -o 
/home/jdb/.cache/nim/test_d/@mtest.nim.c.o 
/home/jdb/.cache/nim/test_d/@mtest.nim.c' failed with exit code: 1

If I modify the test invocation (shown below) to pass `--passC:-fpermissive` it 
compiles successfully and the tests pass.
    
    
    diff --git a/docopt.nimble b/docopt.nimble
    index 5b028b8..5f49379 100644
    --- a/docopt.nimble
    +++ b/docopt.nimble
    @@ -8,6 +8,6 @@ requires "nim >= 0.20.0"
     requires "regex >= 0.11.1"
     
     task test, "Test":
    -  exec "nimble c --verbosity:0 -r -y test/test"
    +  exec "nimble c --verbosity:0 -r -y test/test --passC:-fpermissive"
       for f in listFiles("examples"):
    -    if f[^4..^1] == ".nim": exec "nimble compile --verbosity:0 --hints:off 
" & f
    +    if f[^4..^1] == ".nim": exec "nimble compile --verbosity:0 --hints:off 
--passC:-fpermissive " & f
    
    Run

The relevant lines from docopt (as best I can tell) seem to be:
    
    
    # lines 85-87
    type
      MatchResult = tuple[matched: bool; left, collected: seq[Pattern]]
      SingleMatchResult = tuple[pos: int, match: Pattern]
    
    # lines 234-238
    method single_match(self: Argument, left: seq[Pattern]): SingleMatchResult =
      for n, pattern in left:
        if pattern.class == "Argument":
          return (n, argument(self.name, pattern.value))
      raise new_exception(ValueError, "Not found")
    
    # lines 240-247
    method single_match(self: Command, left: seq[Pattern]): SingleMatchResult =
      for n, pattern in left:
        if pattern.class == "Argument":
          if pattern.value.kind == vkStr and $pattern.value == self.name:
            return (n, command(self.name, val(true)))
          else:
            break
      raise new_exception(ValueError, "Not found")
    
    Run

I didn't see any related issues in GitHub. I'm happy to create one.

Reply via email to