Not replacing all letters.

Pages: 12
closed account (48T7M4Gy)
I still maintain that warnings should be looked at


I have never maintained otherwise and wouldn't.

As I said I was well aware of the warnings and that's all they are - warnings - albeit pedantic.

Further, they don't constitute a crash as the OP mentioned. The program I wrote performed as I both intended and tested using four different compilers - 3 of which were online, all of which are state of the art and equivalent to your choice.

1. The warning on alphabet[] being set but not used is plain wrong! Delete the line and see what happens.

2. The warning on int vs unsigned int is valid as a warning but is meaningless in the context of my program. The warning or any (impossible) misinterpretation that could remotely eventuate is trivial and not relevant to this exercise.

3. The warning on the trigraph shows a bug in the compiler not a fault in the construction of the string array. There is no sensible reason why it would change the value. I assume(d) there is some esoteric '\' or similar that is required according to this compiler. My program does not address decryption, so the warning and any tangential observation is trivial.
@Ch1156

Code::Blocks seems to segfault just prior to return 0; (line 26) in the Debug Target for some reason, but not in the Release Target, which is annoying - there is nothing wrong with the functioning of the code and this doesn't happen with other IDE's I have used. I put a std::cout on line 25 and it worked.

@kemort

I have never maintained otherwise and wouldn't.

As I said I was well aware of the warnings and that's all they are - warnings - albeit pedantic.


Ok, I get that. I recommended that the OP use your code, I am sure he appreciates your effort, and I think that it has helped him.

Sorry to be so stubborn, but ......

1. I guess the compiler considers lines 9 & 10 to be initialisation - which it is, really.

2. Ok

3. I still think you are wrong about that. The compiler has changed "??!" to "|" , which affects the output making it different to what might have been expected. Even though your program isn't doing decryption, it is not doing the encryption as expected (at least for some compilers). I would rather know about it now, so some action could be taken. I changed the "??!" to "*?!" , so it is no longer a tri-graph. The other thing to do would be to disable trigraphs with the appropriate compiler flag. -Wno-trigraphs

And it is a fault in the construction of the string array - if you look at the output, there is no "??!", it is changed to "|". The "sensible reason" why it would change the value, is that it is a trigraph. And it is not a compiler bug, Trigraphs are enabled with -Wall under g++ . Although I had read somewhere that Trigraphs are being removed in C++17 standard? Even if whatever compiler being used is not the latest - it is still a problem isn't it? Had this warning not been mentioned, it would have caused the OP problems.

Anyway, the problems were easily fixed - and I am voting that we have given this enough air time already.

closed account (48T7M4Gy)
@TheIdeasMan
I am voting that we have given this enough air time already.


You can't apologize for directing your comments at the wrong person, then make pronouncements about compilers based on guesses and just walk away from it old son, all on the strength of a unilateral vote. That's neither democratic nor fair.

Let's look at your replies:
1. A guess is a guess and the warning is at line 6 not lines 9 and 10. Line 6 warning says alphabet is unused which is clearly not the case - alphabet is being used at line 10 and that line is not initialization, the RHS of line 6 is!

2. At least we can agree on something :)

3. The apparent interpretation by the compiler of a string of 3 characters enclosed in double quotes as an element in a string array may very well be a trigraph. I agree with your comment earlier that it can't be ignored in the decryption phase, at least on this crap compiler. My point is though, where in the c++ or compiler documentation is there any such restriction and need for a warning and correction? My assessment is the warning is incorrect and effectively a bug especially because making the change is a compiler error.

Cheers :)

http://stackoverflow.com/questions/1234582/purpose-of-trigraph-sequences-in-c
Last edited on
Topic archived. No new replies allowed.
Pages: 12